Skip to content

Commit

Permalink
json_vprintf(): fix crashing upon a %% in format
Browse files Browse the repository at this point in the history
  • Loading branch information
QRPp committed Feb 12, 2021
1 parent d52032f commit 1edd889
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/frozen/frozen.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ int json_vprintf(struct json_out *out, const char *fmt, va_list xap) {

const char *end_of_format_specifier = "sdfFeEgGlhuIcx.*-0123456789";
int n = strspn(fmt + 1, end_of_format_specifier);
if (n == 0 && fmt[1] == '%') n = 1;
char *pbuf = buf;
int need_len, size = sizeof(buf);
char fmt2[20];
Expand Down Expand Up @@ -710,6 +711,8 @@ int json_vprintf(struct json_out *out, const char *fmt, va_list xap) {
case 'p':
(void) va_arg(ap, void *);
break;
case '%':
break;
default:
/* many types are promoted to int */
(void) va_arg(ap, int);
Expand Down

0 comments on commit 1edd889

Please sign in to comment.