|
From: | Paul Eggert |
Subject: | Re: critique of gnulib |
Date: | Sat, 31 Aug 2019 16:20:35 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
Bruno Haible wrote:
https://gitlab.com/sortix/sortix/wikis/Gnulibsprintf 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
[Prev in Thread] | Current Thread | [Next in Thread] |