From: Quentin Rameau Date: Sun, 11 Nov 2018 08:25:26 +0000 (+0100) Subject: fix memccpy to not access buffer past given size X-Git-Tag: v1.1.21~23 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d9bdfd164;p=oweals%2Fmusl.git fix memccpy to not access buffer past given size memccpy would return a pointer over the given size when c is not found in the source buffer and n reaches 0. --- diff --git a/src/string/memccpy.c b/src/string/memccpy.c index f515581c..00c18e2b 100644 --- a/src/string/memccpy.c +++ b/src/string/memccpy.c @@ -29,6 +29,6 @@ void *memccpy(void *restrict dest, const void *restrict src, int c, size_t n) #endif for (; n && (*d=*s)!=c; n--, s++, d++); tail: - if (*s==c) return d+1; + if (n && *s==c) return d+1; return 0; }