David Chisnall wrote: > On 27 May 2013, at 18:18, Ivan Vučica <[email protected]> wrote: > >> Somewhat off topic: I really like the following error; it's extremely >> professional and mature. Where is it coming from? >> >> /usr/local/lib/libgcrypt.so.18.0: warning: stpcpy() is dangerous GNU crap; >> don't use it > > It's a linker error that is triggered by the presence of an attribute on a > function. The text is a reference to Ulrich Drepper's refusal to accept > patches to implement the strl* functions in glibc because they were > 'inefficient BSD crap'. > > It is 'dangerous', because it will NULL-terminate the string in some cases, > but not others. This means that you must always check the lengths of both > strings before calling it, at which point you may as well use memcpy, which > will be faster.
Don't get things mixed up. :-) stpcpy and strcpy are dangerous because these functions might overrun the buffer you are writing to. It is strpncpy and strncpy, which may fail to write a '\0' to the end of the string. > Note, however, that the GNU man page explicitly claims not to have invented > this function, and it is now part of POSIX2008 (Austin has a habit of > standardising bad ideas if two or more libcs have implemented them), so the > 'GNU' in the warning is misleading. Wolfgang _______________________________________________ Discuss-gnustep mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnustep
