os: fix pnprintf OOB buffer read for unterminated length modifiers

Format strings with length modifiers but missing format specifier like "%0"
will read one byte past the array size.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Peter Hutterer
2013-02-14 16:31:13 +10:00
committed by Keith Packard
parent 955d434f4d
commit 9a35d4240e
2 changed files with 11 additions and 0 deletions

View File

@@ -304,6 +304,9 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
while (f_idx < f_len && ((f[f_idx] >= '0' && f[f_idx] <= '9') || f[f_idx] == '.'))
f_idx++;
if (f_idx >= f_len)
break;
switch (f[f_idx]) {
case 's':
string_arg = va_arg(args, char*);