Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.91k stars 542 forks source link

strlcpy instead of strncpy #7437

Closed p5pRT closed 19 years ago

p5pRT commented 20 years ago

Migrated from rt.perl.org#30838 (status was 'resolved')

Searchable as RT30838$

p5pRT commented 20 years ago

From @eserte

This is a bug report for perl from slaven@​rezic.de\, generated with the help of perlbug 1.34 running under perl v5.8.0.


Today I learned about the strlcpy function as a strncpy replacement. At least some *BSD systems support this function. There is one occurrence of strncpy in ext/Cwd/Cwd.xs which could be replaced by strlcpy.

See also the strlcpy manpage on *BSD and http​://www.courtesan.com/todd/papers/strlcpy.html



Flags​:   category=core   severity=wishlist


Site configuration information for perl v5.8.0​:

Configured by davidk at Sun Apr 6 15​:15​:05 CEST 2003.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration​:   Platform​:   osname=linux\, osvers=2.4.18-14\, archname=i686-linux   uname='linux devpc01.iconmobile.de 2.4.18-14 #1 wed sep 4 13​:35​:50 edt 2002 i686 i686 i386 gnulinux '   config_args='-de'   hint=recommended\, useposix=true\, d_sigaction=define   usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef   useperlio=define d_sfio=undef uselargefiles=define usesocks=undef   use64bitint=undef use64bitall=undef uselongdouble=undef   usemymalloc=n\, bincompat5005=undef   Compiler​:   cc='cc'\, ccflags ='-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm'\,   optimize='-O3'\,   cppflags='-fno-strict-aliasing -I/usr/include/gdbm'   ccversion=''\, gccversion='3.2 20020903 (Red Hat Linux 8.0 3.2-7)'\, gccosandvers=''   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=1234   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=12   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8   alignbytes=4\, prototype=define   Linker and Libraries​:   ld='cc'\, ldflags =' -L/usr/local/lib'   libpth=/usr/local/lib /lib /usr/lib   libs=-lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt -lutil   perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil   libc=/lib/libc-2.2.93.so\, so=so\, useshrplib=false\, libperl=libperl.a   gnulibc_version='2.2.93'   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags='-rdynamic'   cccdlflags='-fpic'\, lddlflags='-shared -L/usr/local/lib'

Locally applied patches​:  


@​INC for perl v5.8.0​:   /usr/local/lib/perl5/5.8.0/i686-linux   /usr/local/lib/perl5/5.8.0   /usr/local/lib/perl5/site_perl/5.8.0/i686-linux   /usr/local/lib/perl5/site_perl/5.8.0   /usr/local/lib/perl5/site_perl   .


Environment for perl v5.8.0​:   HOME=/home/slavenr   LANG (unset)   LANGUAGE (unset)   LD_LIBRARY_PATH (unset)   LOGDIR (unset)   PATH=/usr/X11R6/bin​:/usr/X11/bin​:/usr/local/bin​:/usr/ucb​:/usr/bin​:/bin​:/usr/gnu/bin​:/usr/TeX/bin​:/usr/etc​:/usr/local/lib​:/usr/local/etc​:/usr/local/sbin​:/usr/sbin​:/sbin​:/home/slavenr/bin/linux​:/home/slavenr/bin/sh​:/home/slavenr/bin​:/usr/www/bin​:/usr/sepia/bin​:/usr/informix/online/bin​:/usr/local/Hughes/bin​:/usr/motif/bin​:/usr/cctb/bin​:/usr/sas​:/usr/ocs/bin​:/home/autos/bin​:/usr/games​:/home/pub/bin/linux​:/home/pub/bin​:/home/pub/bin/pbmplus​:/home/slavenr/devel/fahrinfo​:/home/slavenr/devel​:/opt/kde2/bin​:/opt/kde/bin​:/opt/gnome/bin​:/epoc/nokia60/epoc32/tools​:/usr/local/er6/bin/   PERL_BADLANG (unset)   SHELL=/bin/tcsh

p5pRT commented 20 years ago

From @rgs

slaven@​rezic.de (via RT) wrote​:

Today I learned about the strlcpy function as a strncpy replacement. At least some *BSD systems support this function. There is one occurrence of strncpy in ext/Cwd/Cwd.xs which could be replaced by strlcpy.

This probably involves adding a Configure probe for strlcpy. Better tested on a system that supports it :)

p5pRT commented 20 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 20 years ago

From @smpeters

Today I learned about the strlcpy function as a strncpy replacement. At least some *BSD systems support this function. There is one occurrence of strncpy in ext/Cwd/Cwd.xs which could be replaced by strlcpy.

This probably involves adding a Configure probe for strlcpy. Better tested on a system that supports it :)

The problem is that Cwd is a module that is maintained outside of the Perl core. While adding a Configure probe would work fine for the install of Perl\, the module author would need to handle this during the module build as well.

p5pRT commented 20 years ago

From @smpeters

Today I learned about the strlcpy function as a strncpy replacement. At least some *BSD systems support this function. There is one occurrence of strncpy in ext/Cwd/Cwd.xs which could be replaced by strlcpy.

This probably involves adding a Configure probe for strlcpy. Better tested on a system that supports it :)

The problem is that Cwd is a module that is maintained outside of the Perl core. While adding a Configure probe would work fine for the install of Perl\, the module author would need to handle this during the module build as well.

p5pRT commented 20 years ago

From @tux

On Tue 14 Sep 2004 05​:08\, "Steve Peters via RT" \bugs\-perl5@​bugs6\.perl\.org wrote​:

Today I learned about the strlcpy function as a strncpy replacement. At least some *BSD systems support this function. There is one occurrence of strncpy in ext/Cwd/Cwd.xs which could be replaced by strlcpy.

This probably involves adding a Configure probe for strlcpy. Better tested on a system that supports it :)

The problem is that Cwd is a module that is maintained outside of the Perl core. While adding a Configure probe would work fine for the install of Perl\, the module author would need to handle this during the module build as well.

But knowing form %Config if it's there would help.

This is still on my todo list.

-- H.Merijn Brand Amsterdam Perl Mongers (http​://amsterdam.pm.org/) using perl-5.6.1\, 5.8.3\, & 5.9.x\, and 809 on HP-UX 10.20 & 11.00\, 11i\,   AIX 4.3\, SuSE 9.0\, and Win2k. http​://www.cmve.net/~merijn/ http​://archives.develooper.com/daily-build@​perl.org/ perl-qa@​perl.org send smoke reports to​: smokers-reports@​perl.org\, QA​: http​://qa.perl.org

p5pRT commented 19 years ago

From @smpeters

[slaven@​rezic.de - Tue Jul 27 02​:07​:30 2004]​:

This is a bug report for perl from slaven@​rezic.de\, generated with the help of perlbug 1.34 running under perl v5.8.0.

----------------------------------------------------------------- Today I learned about the strlcpy function as a strncpy replacement. At least some *BSD systems support this function. There is one occurrence of strncpy in ext/Cwd/Cwd.xs which could be replaced by strlcpy.

Configure now detects strlcpy() and strlcat(). The presence of these functions can be probed in %Config in the current bleadperl.

p5pRT commented 19 years ago

@smpeters - Status changed from 'open' to 'resolved'