aboutsummaryrefslogtreecommitdiff
path: root/string/bits
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2015-08-14 09:21:44 -0400
committerMike Frysinger <vapier@gentoo.org>2015-08-14 22:40:19 -0400
commit8ff5e0ec497613e578219c9c3d49053c550b9269 (patch)
treed35487ff0ad78c4f404883dcb2a0f7835a85137e /string/bits
parent739babd775d4b69525e3494cad4310742a9b360a (diff)
downloadglibc-8ff5e0ec497613e578219c9c3d49053c550b9269.zip
glibc-8ff5e0ec497613e578219c9c3d49053c550b9269.tar.gz
glibc-8ff5e0ec497613e578219c9c3d49053c550b9269.tar.bz2
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.
Diffstat (limited to 'string/bits')
-rw-r--r--string/bits/string3.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/string/bits/string3.h b/string/bits/string3.h
index f482935..4d11aa6 100644
--- a/string/bits/string3.h
+++ b/string/bits/string3.h
@@ -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);
}