Bruno Haible wrote:
https://gitlab.com/sortix/sortix/wikis/Gnulib
sprintf calls.
What do you mean? sprintf is a standardized libc function.

I imagine Jonas is referring to the practice of avoiding sprintf and using snprintf instead, under the theory that sprintf can be dangerous. Gnulib does not follow that practice; instead, it avoids dangerous uses of sprintf. Similarly for strcpy and for several other C functions that can be dangerous if misused.

The Gnulib style for sprintf helps avoid the common problem of inadvertently truncating strings.[1] Admittedly (and as Bruno knows) this has long been a controversial area.[2][3]

[1] https://wiki.sei.cmu.edu/confluence/display/c/STR03-C.+Do+not+inadvertently+truncate+a+string
[2] https://lists.gnu.org/archive/html/bug-gnulib/2004-09/msg00181.html
[3] https://sourceware.org/ml/libc-alpha/2002-01/msg00133.html

Reply via email to