projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
39ef612
)
fix memccpy to not access buffer past given size
author
Quentin Rameau
<quinq@fifth.space>
Sun, 11 Nov 2018 08:25:26 +0000
(09:25 +0100)
committer
Rich Felker
<dalias@aerifal.cx>
Sun, 2 Dec 2018 14:24:15 +0000
(09:24 -0500)
memccpy would return a pointer over the given size when c is not
found in the source buffer and n reaches 0.
src/string/memccpy.c
patch
|
blob
|
history
diff --git
a/src/string/memccpy.c
b/src/string/memccpy.c
index f515581cd3d92c4e7129a9753d0485cad14b8314..00c18e2b5b567bbbd51435f058203d1c59bad040 100644
(file)
--- 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;
}