diff options
author | Keuin <[email protected]> | 2022-05-28 01:26:32 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-05-28 01:26:32 +0800 |
commit | 3064ce6bfa8669f86c58ed74fb3f737671ec7fb1 (patch) | |
tree | c5576cfa4d5965f2229f9be7f579fc9b04edc6ed /main.c | |
parent | 15305a1351d9f7eb36b444ebd693f78a38600af0 (diff) |
Bugfix: buggy pkcs7 unpad implementation. SEGV when n=1.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -117,6 +117,10 @@ bool yield_possible_key( * the data is not padded with valid pkcs7 */ int pkcs7_check_pad(const char *buf, size_t n) { if (!n) return -1; + if (n == 1) { + /* if total length is 1, the only valid string is 0x1 */ + return (buf[0] == 1u) ? 1 : -1; + } --n; unsigned char pad = buf[n--]; if (!pad) return -1; |