diff options
| -rw-r--r-- | lib/test_hexdump.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/test_hexdump.c b/lib/test_hexdump.c index 16a759374730..11d45f510d6c 100644 --- a/lib/test_hexdump.c +++ b/lib/test_hexdump.c | |||
| @@ -133,7 +133,9 @@ static void __init test_hexdump_set(int rowsize, bool ascii) | |||
| 133 | test_hexdump(len, rowsize, 1, ascii); | 133 | test_hexdump(len, rowsize, 1, ascii); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | static void __init test_hexdump_overflow(size_t buflen, bool ascii) | 136 | static void __init test_hexdump_overflow(size_t buflen, size_t len, |
| 137 | int rowsize, int groupsize, | ||
| 138 | bool ascii) | ||
| 137 | { | 139 | { |
| 138 | char test[TEST_HEXDUMP_BUF_SIZE]; | 140 | char test[TEST_HEXDUMP_BUF_SIZE]; |
| 139 | char buf[TEST_HEXDUMP_BUF_SIZE]; | 141 | char buf[TEST_HEXDUMP_BUF_SIZE]; |
| @@ -176,6 +178,19 @@ static void __init test_hexdump_overflow(size_t buflen, bool ascii) | |||
| 176 | } | 178 | } |
| 177 | } | 179 | } |
| 178 | 180 | ||
| 181 | static void __init test_hexdump_overflow_set(size_t buflen, bool ascii) | ||
| 182 | { | ||
| 183 | unsigned int i = 0; | ||
| 184 | int rs = (get_random_int() % 2 + 1) * 16; | ||
| 185 | |||
| 186 | do { | ||
| 187 | int gs = 1 << i; | ||
| 188 | size_t len = get_random_int() % rs + gs; | ||
| 189 | |||
| 190 | test_hexdump_overflow(buflen, rounddown(len, gs), rs, gs, ascii); | ||
| 191 | } while (i++ < 3); | ||
| 192 | } | ||
| 193 | |||
| 179 | static int __init test_hexdump_init(void) | 194 | static int __init test_hexdump_init(void) |
| 180 | { | 195 | { |
| 181 | unsigned int i; | 196 | unsigned int i; |
| @@ -192,10 +207,10 @@ static int __init test_hexdump_init(void) | |||
| 192 | test_hexdump_set(rowsize, true); | 207 | test_hexdump_set(rowsize, true); |
| 193 | 208 | ||
| 194 | for (i = 0; i <= TEST_HEXDUMP_BUF_SIZE; i++) | 209 | for (i = 0; i <= TEST_HEXDUMP_BUF_SIZE; i++) |
| 195 | test_hexdump_overflow(i, false); | 210 | test_hexdump_overflow_set(i, false); |
| 196 | 211 | ||
| 197 | for (i = 0; i <= TEST_HEXDUMP_BUF_SIZE; i++) | 212 | for (i = 0; i <= TEST_HEXDUMP_BUF_SIZE; i++) |
| 198 | test_hexdump_overflow(i, true); | 213 | test_hexdump_overflow_set(i, true); |
| 199 | 214 | ||
| 200 | return -EINVAL; | 215 | return -EINVAL; |
| 201 | } | 216 | } |
