https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104969

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
That's not the intended reading of the POSIX text.  But (outside of extensions
for behavior C leaves undefined) POSIX defers to C, so the authoritative text
is there.  C doesn't impose any requirement on the size argument.

That said, specifying a snprintf size that's bigger than the space in the
provided buffer is certainly asking for trouble, even more so than doing the
same with strncmp.  GCC should be enhanced to warn about that when possible
(pr83430 tracks the request), although I suspect that wouldn't help in this
case.

For the constant subset of instances Clang issues warning: 'snprintf' size
argument is too large; destination buffer has size 4, but size argument is 7
[-Wfortify-source].

Reply via email to