LWN.net Logo

A turning point for GNU libc

A turning point for GNU libc

Posted Mar 28, 2012 17:40 UTC (Wed) by Cyberax (✭ supporter ✭, #52523)
In reply to: A turning point for GNU libc by arjan
Parent article: A turning point for GNU libc

How about a function which just does abort() in case of overflow?


(Log in to post comments)

A turning point for GNU libc

Posted Mar 28, 2012 17:45 UTC (Wed) by slashdot (guest, #22014) [Link]

strcpy_s in the Microsoft CRT does that (unless you explicitly set an error handler).

A turning point for GNU libc

Posted Mar 28, 2012 17:48 UTC (Wed) by Cyberax (✭ supporter ✭, #52523) [Link]

Good for them. IMO, that's the only correct behavior in this case.

A turning point for GNU libc

Posted Mar 28, 2012 21:45 UTC (Wed) by dashesy (subscriber, #74652) [Link]

Accepting the useful strcpy_s however can open the can of worms (strncpy_s and the rest of that family)

A turning point for GNU libc

Posted Mar 28, 2012 18:25 UTC (Wed) by arjan (subscriber, #36785) [Link]

that's what strcpy() does...

but yes, that's one of the options, and as default behavior it's not all that bad (it means you can have a crash dump collector detect it and send it to the developer team).
Just it's also a death-sentence kind of API, you also want a variant which is "try to see if it fits, but if it doesn't let me know and I'll handle it gracefully"....

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