1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

stpncpy: fix size checking [BZ #18975]

I think the last clause of the conditional,

	|| __n <= __bos (__dest)

may be backward.  The code should call the runtime-checking function
if __n is not constant, or if __n is known to be LARGER than the size
of the destination.
This commit is contained in:
Zack Weinberg
2015-08-14 09:21:44 -04:00
committed by Mike Frysinger
parent 739babd775
commit 8ff5e0ec49
4 changed files with 172 additions and 13 deletions

View File

@ -136,7 +136,7 @@ __fortify_function char *
__NTH (stpncpy (char *__dest, const char *__src, size_t __n))
{
if (__bos (__dest) != (size_t) -1
&& (!__builtin_constant_p (__n) || __n <= __bos (__dest)))
&& (!__builtin_constant_p (__n) || __n > __bos (__dest)))
return __stpncpy_chk (__dest, __src, __n, __bos (__dest));
return __stpncpy_alias (__dest, __src, __n);
}