| 3 | extern "C" { |
| 4 | |
| 5 | int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) { |
| 6 | try { |
| 7 | // step 1: parse input |
| 8 | const auto jwt1 = jwt::decode(std::string{(char*)Data, Size}); |
| 9 | |
| 10 | try { |
| 11 | // step 2: round trip |
| 12 | std::string s1 = jwt1.get_token(); |
| 13 | const auto jwt2 = jwt::decode(s1); |
| 14 | |
| 15 | // tokens must match |
| 16 | if (s1 != jwt2.get_token()) abort(); |
| 17 | } catch (...) { |
| 18 | // parsing raw data twice must not fail |
| 19 | abort(); |
| 20 | } |
| 21 | } catch (...) { |
| 22 | // parse errors are ok, because input may be random bytes |
| 23 | } |
| 24 | |
| 25 | return 0; // Non-zero return values are reserved for future use. |
| 26 | } |
| 27 | } |