LWN.net Logo

Glibc and strlcpy

Glibc and strlcpy

Posted Dec 18, 2004 5:53 UTC (Sat) by ncm (subscriber, #165)
In reply to: Students uncover dozens of Unix software flaws (News.com) by pjdc
Parent article: Students uncover dozens of Unix software flaws (News.com)

Ulrich is right, as far as he goes.

However, by not providing bindings for functions with those names, he encourages sloppy programmers porting programs that call them to grab the BSD implementation and add it in.

If Glibc were to implement strlcpy etc. but, instead of returning a value to be checked, simply log an error and call abort(), then the bugs would have attention called to them. They could not just silently fail no matter how sloppily coded. Of course, sloppy code shouldn't be run at all (there are a lot more ways to fail than strcpy!). A program that is always aborting is less likely to be run. Problem solved.


(Log in to post comments)

Glibc and strlcpy

Posted Jan 2, 2005 9:54 UTC (Sun) by raboofje (guest, #26972) [Link]

I would think that's a pretty bad idea: it introduces a `crash' at run-time rather than at compile-time. If the error is, for example, in some rarely-encountered but vital error-handling code, you might get bitten hard.

The ability to see these kind of things at compile-time is one of the main reasons I often choose compiled languages over interpreted ones.

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