1
0
Fork 0
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:
Jens Arnold 2004-04-22 21:19:33 +00:00
parent 6cfcc6ccde
commit 4f7956c206

View file

@ -154,7 +154,7 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
va_end(ap);
/* 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;
}
@ -171,7 +171,7 @@ int vsnprintf(char *buf, int size, const char *fmt, va_list ap)
ok = format(sprfunc, &pr, fmt, ap);
/* 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;
}