[Bug c/94615] -Wstringop-truncation warns on strncpy() with struct lastlog (or utmp)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94615 Richard Biener changed: What|Removed |Added Keywords||diagnostic --- Comment #1 from Richard Biener --- Maybe use memcpy then, str* routines generally expect nul-termination
[Bug c/94615] -Wstringop-truncation warns on strncpy() with struct lastlog (or utmp)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94615 Florian Weimer changed: What|Removed |Added CC||fw at gcc dot gnu.org --- Comment #2 from Florian Weimer --- (In reply to Allison Karlitskaya from comment #0) > GCC 8 gives this warning, though: > > /usr/include/bits/string_fortified.h:106:10: warning: '__builtin_strncpy' > specified bound 256 equals destination size [-Wstringop-truncation] > > ... which on its face seems kinda funny, because the bound *should* equal > the destination size. Particularly in this case. If this is true (of which I'm not yet sure), we are missing a nonstring attribute in the glibc header. Either way, it's not a GCC bug, sorry.
[Bug c/94615] -Wstringop-truncation warns on strncpy() with struct lastlog (or utmp)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94615 --- Comment #3 from Allison Karlitskaya --- (In reply to Richard Biener from comment #1) > Maybe use memcpy then, str* routines generally expect nul-termination "str* routines generally expect nul-termination" doesn't really fly as an argument, I'm afraid. I'm using strncpy() because I've very carefully read the manpage and determined that its standards-specified behaviour is exactly what I want, and this behaviour specifically includes the possibility of no nul termination. (In reply to Florian Weimer from comment #2) > If this is true (of which I'm not yet sure), we are missing a nonstring > attribute in the glibc header. Either way, it's not a GCC bug, sorry. That's really useful information. I didn't know that this attribute already exists. Now just to convince the glibc people to add it...
[Bug c/94615] -Wstringop-truncation warns on strncpy() with struct lastlog (or utmp)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94615 Allison Karlitskaya changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #4 from Allison Karlitskaya --- Looks like they already added it for utmp, but not for lastlog: https://sourceware.org/bugzilla/show_bug.cgi?id=24899 I'll file a new bug over there. I guess this bug can probably be closed now. Thanks for the pointer!
[Bug c/94615] -Wstringop-truncation warns on strncpy() with struct lastlog (or utmp)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94615 Allison Karlitskaya changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=94626 --- Comment #5 from Allison Karlitskaya --- See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94626