diff options
author | Jack Lloyd <[email protected]> | 2018-09-23 12:43:11 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-09-23 12:46:06 -0400 |
commit | b859e175a0f2357dcfe2211ca487a7bde0e971b1 (patch) | |
tree | c11f11e92af99d41c8c3f3ad35cb6ae52f480e95 | |
parent | 97c7a8bf1d8af210b300b4d88a488b1c4cdaaa97 (diff) |
Fix a crash in the mode padding fuzzer
The reference version of 1and0 padding would crash on an all-zero input.
OSS-Fuzz 10628
-rw-r--r-- | src/fuzzer/mode_padding.cpp | 2 | ||||
-rw-r--r-- | src/tests/data/pad.vec | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/fuzzer/mode_padding.cpp b/src/fuzzer/mode_padding.cpp index 05cb1a8f6..985ea25e3 100644 --- a/src/fuzzer/mode_padding.cpp +++ b/src/fuzzer/mode_padding.cpp @@ -62,6 +62,8 @@ size_t ref_oneandzero_unpad(const uint8_t in[], size_t len) { if(in[idx] == 0) { + if(idx == 0) + return len; idx -= 1; continue; } diff --git a/src/tests/data/pad.vec b/src/tests/data/pad.vec index 54efa4f1d..712d38709 100644 --- a/src/tests/data/pad.vec +++ b/src/tests/data/pad.vec @@ -102,6 +102,9 @@ Blocksize = 8 In = FF70000000000081 Blocksize = 8 +In = 0000000000000000 +Blocksize = 8 + [X9.23] In = FFFFFF Out = FFFFFF0000000000000000000000000D |