diff options
author | Petr Mladek <pmladek@suse.com> | 2019-05-06 10:32:45 +0200 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2019-05-06 10:32:45 +0200 |
commit | 35e1547511fcb035437b4527184458adfb0e8f43 (patch) | |
tree | bd480bed94268701ce68533bc04b96ca3b446fcc /lib/test_printf.c | |
parent | printk: Tie printk_once / printk_deferred_once into .data.once for reset (diff) | |
parent | lib/vsprintf: Make function pointer_string static (diff) | |
download | linux-35e1547511fcb035437b4527184458adfb0e8f43.tar.xz linux-35e1547511fcb035437b4527184458adfb0e8f43.zip |
Merge branch 'for-5.2-vsprintf-hardening' into for-linus
Diffstat (limited to 'lib/test_printf.c')
-rw-r--r-- | lib/test_printf.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/test_printf.c b/lib/test_printf.c index e8206d8d2d08..d5ab4ca4da99 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -239,6 +239,7 @@ plain_format(void) #define PTR ((void *)0x456789ab) #define PTR_STR "456789ab" #define PTR_VAL_NO_CRNG "(ptrval)" +#define ZEROS "" static int __init plain_format(void) @@ -268,7 +269,6 @@ plain_hash_to_buffer(const void *p, char *buf, size_t len) return 0; } - static int __init plain_hash(void) { @@ -326,6 +326,24 @@ test_hashed(const char *fmt, const void *p) } static void __init +null_pointer(void) +{ + test_hashed("%p", NULL); + test(ZEROS "00000000", "%px", NULL); + test("(null)", "%pE", NULL); +} + +#define PTR_INVALID ((void *)0x000000ab) + +static void __init +invalid_pointer(void) +{ + test_hashed("%p", PTR_INVALID); + test(ZEROS "000000ab", "%px", PTR_INVALID); + test("(efault)", "%pE", PTR_INVALID); +} + +static void __init symbol_ptr(void) { } @@ -462,8 +480,7 @@ struct_rtc_time(void) .tm_year = 118, }; - test_hashed("%pt", &tm); - + test("(%ptR?)", "%pt", &tm); test("2018-11-26T05:35:43", "%ptR", &tm); test("0118-10-26T05:35:43", "%ptRr", &tm); test("05:35:43|2018-11-26", "%ptRt|%ptRd", &tm, &tm); @@ -572,6 +589,8 @@ static void __init test_pointer(void) { plain(); + null_pointer(); + invalid_pointer(); symbol_ptr(); kernel_ptr(); struct_resource(); |