forked from len0rd/rockbox
(v)snprintf() wrote past buffer end if string length was equal to buffer size
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4549 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6cfcc6ccde
commit
4f7956c206
1 changed files with 2 additions and 2 deletions
|
@ -154,7 +154,7 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
/* make sure it ends with a trailing zero */
|
/* make sure it ends with a trailing zero */
|
||||||
pr.ptr[ok?0:-1]='\0';
|
pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
|
||||||
|
|
||||||
return pr.bytes;
|
return pr.bytes;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ int vsnprintf(char *buf, int size, const char *fmt, va_list ap)
|
||||||
ok = format(sprfunc, &pr, fmt, ap);
|
ok = format(sprfunc, &pr, fmt, ap);
|
||||||
|
|
||||||
/* make sure it ends with a trailing zero */
|
/* make sure it ends with a trailing zero */
|
||||||
pr.ptr[ok?0:-1]='\0';
|
pr.ptr[(pr.bytes < pr.max) ? 0 : -1] = '\0';
|
||||||
|
|
||||||
return pr.bytes;
|
return pr.bytes;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue