compel/log: Stop parsing at unknown format specifier

Currently if the specifier can't be parsed - error message is printed
and parsing of the format string continues. That's wrong as the argument
for the specifier will be used for the next specifier. I.e:
  pr_info("[%zu]`%s`\n", 0UL, "")
will crash PIE because %u is not known and the argument (0UL) will be
used for dereferencing string for %s.

Stop parsing printf position arguments at an unknown specifier.
Make this string visible so that `grep Error` in zdtm.py will catch it:

=[log]=> dump/zdtm/static/busyloop00/52/1/restore.log
------------------------ grep Error ------------------------
b'(00.001847) pie: 52: vdso: ['
b'Error: Unknown printf format %u'
------------------------ ERROR OVER ------------------------
Send the 15 signal to  52
Wait for zdtm/static/busyloop00(52) to die for 0.100000
======================= Test zdtm/static/busyloop00 PASS =======================

Reported-by: @ashwani29
Signed-off-by: Dmitry Safonov <dima@arista.com>
This commit is contained in:
Dmitry Safonov 2020-11-11 23:14:39 +00:00 committed by Andrei Vagin
parent b93fe2b2d6
commit c39ed518f0

View file

@ -330,9 +330,10 @@ static void sbuf_printf(struct simple_buf *b, const char *format, va_list args)
print_hex_l((unsigned long)va_arg(args, void *), b);
break;
default:
print_string("UNKNOWN FORMAT ", b);
print_string("\nError: Unknown printf format %", b);
sbuf_putc(b, *s);
break;
sbuf_putc(b, '\n');
return;
}
s++;
}