Skip to content

Commit 071df33

Browse files
base64 encoding input to avoid "obvious" exceptions
trying out the EVP_ interface from #89
1 parent 7e21bc0 commit 071df33

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/fuzz/BaseDecodeFuzz.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
#include <jwt-cpp/base.h>
2+
#include <openssl/evp.h>
23

34
extern "C" {
45

56
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
6-
jwt::base::decode<jwt::alphabet::base64>(std::string{(char *)Data, Size});
7+
std::vector<uint8_t> encoded(4*((Size+2)/3, 0);
8+
if(EVP_EncodeBlock(encoded.data(), Data, Size) != encoded.size())
9+
abort(); // Critical error using OpenSSL
10+
11+
jwt::base::decode<jwt::alphabet::base64>(std::string{encoded.begin(), encoded.end()}); // TO DO: Compare against input
712
return 0; // Non-zero return values are reserved for future use.
813
}
9-
}
14+
15+
}

0 commit comments

Comments
 (0)