best practice for packing programs that use strlcpy()?

Daniel P. Berrange berrange at redhat.com
Mon Feb 1 11:00:07 UTC 2010


On Sat, Jan 30, 2010 at 07:32:06PM +0200, shmuel siegel wrote:
> On 1/29/2010 4:50 AM, Tom "spot" Callaway wrote:
> > On 01/28/2010 09:32 PM, Eric Smith wrote:
> >    
> >> What is considered the best practice for packaging a program that uses
> >> strlcpy()?
> >>      
> > Besides patching it to not use strlcpy? :)
> >    
> Is there a reason (from a programming point of view) to avoid 
> strlcpy/strlcat?

They are solving the wrong problem. Just use asprintf() and avoid the 
entire issue of fixed size buffers in the first place. There are times 
when fixed size buffers are important, but much of the C code I see that
uses strcat() would be better off re-written to use asprintf()

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


More information about the devel mailing list