[Bug c/93636] Incorrect diagnostic of a potential string overflow in strncat

sebunger44 at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Feb 10 03:55:00 GMT 2020


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

Sebastian Unger <sebunger44 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |---

--- Comment #2 from Sebastian Unger <sebunger44 at gmail dot com> ---
The (simplified) test-case I gave may be the same as strcat, but the intention
of strncat is not to limit to the size of destination, but to limit the size
taken from source because it may not be null-terminated. So the real test-case
is more like this:

void f(char* dst)
{
  static const char tt[2] = {'a', 'b'};
  strncat(dst, tt, sizeof(tt));
}


More information about the Gcc-bugs mailing list