mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
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.
This commit is contained in:
parent
39ef612aa1
commit
d9bdfd1644
1 changed files with 1 additions and 1 deletions
|
@ -29,6 +29,6 @@ void *memccpy(void *restrict dest, const void *restrict src, int c, size_t n)
|
||||||
#endif
|
#endif
|
||||||
for (; n && (*d=*s)!=c; n--, s++, d++);
|
for (; n && (*d=*s)!=c; n--, s++, d++);
|
||||||
tail:
|
tail:
|
||||||
if (*s==c) return d+1;
|
if (n && *s==c) return d+1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue