Skip to content

Commit

Permalink
Low: log: check for appropriate space when serializing a char
Browse files Browse the repository at this point in the history
... where appropriate space is measured for, surprisingly, a char,
not for an int.  Note that's also the actual type used for both
de-/serializing, so there's no conflict.

Also bother to explain why, now surprisingly for real, an unsigned int
is scraped out from va_list (akin to to STDARG(3)).
  • Loading branch information
jnpkrn committed Jun 17, 2016
1 parent 907e49b commit 17e5a36
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/log_format.c
Expand Up @@ -604,9 +604,10 @@ qb_vsnprintf_serialize(char *serialize, size_t max_len,
int arg_int;
unsigned char arg_char;

if (location + sizeof (unsigned int) > max_len) {
if (location + sizeof (unsigned char) > max_len) {
return max_len;
}
/* va_arg only takes fully promoted types */
arg_int = va_arg(ap, unsigned int);
arg_char = (unsigned char)arg_int;
memcpy (&serialize[location], &arg_char, sizeof (unsigned char));
Expand Down

0 comments on commit 17e5a36

Please sign in to comment.