forked from mirrors/kore
Don't let kore_strlcpy() overflow a buffer that is 1 byte long
This commit is contained in:
parent
f3fe543358
commit
27ec8a1d58
@ -77,12 +77,16 @@ kore_strlcpy(char *dst, const char *src, size_t len)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
const char *end = dst + len - 1;
|
||||
|
||||
while ((*d++ = *s++) != '\0') {
|
||||
if (d == (dst + len - 1)) {
|
||||
while ((*d = *s) != '\0') {
|
||||
if (d == end) {
|
||||
*d = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
d++;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user