The internal vsnprintf_r function looped or crashed on size parameter with hexadecimal output

This commit is contained in:
Gerhard Rieger 2017-01-15 14:35:06 +01:00
parent 0fdd9ceb58
commit 53f528335c
2 changed files with 5 additions and 2 deletions

View file

@ -54,6 +54,9 @@ corrections:
indentation. indentation.
Thanks to Paul Wouters for reporting. Thanks to Paul Wouters for reporting.
The internal vsnprintf_r function looped or crashed on size parameter
with hexadecimal output.
porting: porting:
Type conflict between int and sig_atomic_t between declaration and Type conflict between int and sig_atomic_t between declaration and
definition of diag_immediate_type and diag_immediate_exit broke definition of diag_immediate_type and diag_immediate_exit broke

View file

@ -296,7 +296,7 @@ static char *diag_longlong_to_dec(char *field, size_t n, long long ll, int leadi
*/ */
static char *diag_ulonglong_to_hex(char *field, size_t n, unsigned long long ull, int leading0, size_t size) { static char *diag_ulonglong_to_hex(char *field, size_t n, unsigned long long ull, int leading0, size_t size) {
char *np = field+n; /* point to the end */ char *np = field+n; /* point to the end */
unsigned int i; ptrdiff_t i;
char c; char c;
if (n == 0) return NULL; if (n == 0) return NULL;
@ -313,7 +313,7 @@ static char *diag_ulonglong_to_hex(char *field, size_t n, unsigned long long ull
c = ' '; c = ' ';
} }
i = size - strlen(np); i = size - strlen(np);
while (--i >= 0) { while (i-- > 0) {
*--np = c; *--np = c;
} }
} }