LWN.net Logo

That's a non-problem

That's a non-problem

Posted May 21, 2009 17:16 UTC (Thu) by spitzak (guest, #4593)
In reply to: That's a non-problem by elanthis
Parent article: EGLIBC: Not a fork, but a glibc distribution

<i>strlcpy protects against buffer overflows, but what you really want to do is check before hand anyway and either error out or allocate a larger buffer,</i>

You seem to have missed the fact that strlcpy returns the size of the buffer that would be needed. You have a free test to see if the buffer needs to be reallocated. And if not, how about that, the copy is done, and you don't have to do another call!

The arguments againsts strl* are just stupid now. It is pretty obvious that it is what everybody wants.


(Log in to post comments)

That's a non-problem

Posted May 22, 2009 11:29 UTC (Fri) by liljencrantz (subscriber, #28458) [Link]

Speaking as somebody who does occasionally use strlcpy, I'm not sure I agree with that everyone wants strlcpy. The counterargument is that extremely few projects use them, so they would waste memory in the shared library, since they'd likelyu be paged in all the time because they're on the same page as actually _used_ functions. And for no benefit, since very few people use C for direct string manipulation, and those that do perform heavy duty string manipulations use a container library, and not raw C strings.

I don't know if that argument is true, but I did a quick grep of my s?bin-folders (Plain Ubuntu Handy Hardon system), and though there are a few dozen instances of programs that use strlcpy, none of them are running right now on my system, so for me personally, including them _would_ waste memory. Gimp, totem, and sftp uses it, though, and maybe the users of those applications are a majority. I honestly don't know.

That's a non-problem

Posted May 25, 2009 13:41 UTC (Mon) by wawjohn (subscriber, #509) [Link]

Good thing I had already finished my cup of coffee when I read your OS
version description:

> Plain Ubuntu Handy Hardon system

Got any more 'corrected' names for other Ubuntu releases?

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds