mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 08:25:38 +00:00
base: handle unsupported printf commands better
The commit consumes the argument of a unsupported printf command. Without the commit - a subsequent command uses the argument of the preceding command, which may cause memory corruption or page faults for sequences using string commands, e.g. Genode::printf("%#x %s\n", 0x20, "Test"); '#' is not supported by Genode::printf. In this scenario a pagefault at address 0x20 is caused. Fixes #1701
This commit is contained in:
parent
5309bda8b6
commit
9b21c88bc6
@ -335,6 +335,8 @@ void Console::vprintf(const char *format, va_list list)
|
||||
case Format_command::INVALID:
|
||||
|
||||
_out_string("<warning: unsupported format string argument>");
|
||||
/* consume the argument of the unsupported command */
|
||||
va_arg(list, long);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,10 @@
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* test that unsupported commands don't crash the printf parser */
|
||||
Genode::printf("%#x %s\n", 0x38, "test 1");
|
||||
Genode::printf("%#lx %s\n", 0x38L, "test 2");
|
||||
|
||||
Genode::printf("-1 = %d = %ld\n", -1, -1L);
|
||||
|
||||
return 0;
|
||||
|
@ -55,3 +55,4 @@ stdcxx
|
||||
nic_loopback
|
||||
platform
|
||||
report_rom
|
||||
printf
|
||||
|
Loading…
x
Reference in New Issue
Block a user