_ZN4chip9ChipErrorC2EjPKcj:
  190|  5.69M|        mError(error) CHIP_INITIALIZE_ERROR_SOURCE(file, line, /*loc=*/nullptr)
  ------------------
  |  |  122|  5.69M|#define CHIP_INITIALIZE_ERROR_SOURCE(f, l, loc) , mFile((f)), mLine((l))
  ------------------
  191|  5.69M|    {}
_ZNK4chip9ChipErrorneERKS0_:
  204|  2.84M|    bool operator!=(const ChipError & other) const { return mError != other.mError; }

_ZN4chip12base38DecodeENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEERNS0_6vectorIhNS4_IhEEEE:
   99|    179|{
  100|    179|    result.clear();
  101|       |
  102|    179|    size_t base38CharactersNumber  = base38.length();
  103|    179|    size_t decodedBase38Characters = 0;
  104|   569k|    while (base38CharactersNumber > 0)
  ------------------
  |  Branch (104:12): [True: 569k, False: 41]
  ------------------
  105|   569k|    {
  106|   569k|        uint8_t base38CharactersInChunk;
  107|   569k|        uint8_t bytesInDecodedChunk;
  108|       |
  109|   569k|        if (base38CharactersNumber >= kBase38CharactersNeededInNBytesChunk[2])
  ------------------
  |  Branch (109:13): [True: 569k, False: 68]
  ------------------
  110|   569k|        {
  111|   569k|            base38CharactersInChunk = kBase38CharactersNeededInNBytesChunk[2];
  112|   569k|            bytesInDecodedChunk     = 3;
  113|   569k|        }
  114|     68|        else if (base38CharactersNumber == kBase38CharactersNeededInNBytesChunk[1])
  ------------------
  |  Branch (114:18): [True: 17, False: 51]
  ------------------
  115|     17|        {
  116|     17|            base38CharactersInChunk = kBase38CharactersNeededInNBytesChunk[1];
  117|     17|            bytesInDecodedChunk     = 2;
  118|     17|        }
  119|     51|        else if (base38CharactersNumber == kBase38CharactersNeededInNBytesChunk[0])
  ------------------
  |  Branch (119:18): [True: 39, False: 12]
  ------------------
  120|     39|        {
  121|     39|            base38CharactersInChunk = kBase38CharactersNeededInNBytesChunk[0];
  122|     39|            bytesInDecodedChunk     = 1;
  123|     39|        }
  124|     12|        else
  125|     12|        {
  126|     12|            return CHIP_ERROR_INVALID_STRING_LENGTH;
  ------------------
  |  |  754|     12|#define CHIP_ERROR_INVALID_STRING_LENGTH                       CHIP_CORE_ERROR(0x1e)
  |  |  ------------------
  |  |  |  |  436|     12|#define CHIP_CORE_ERROR(e) CHIP_SDK_ERROR(::chip::ChipError::SdkPart::kCore, (e))
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|     12|    (::chip::ChipError(::chip::ChipError::SdkErrorConstant<(part), (code)>::value, __FILE__, __LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  127|     12|        }
  128|       |
  129|   569k|        uint32_t value = 0;
  130|       |
  131|  3.41M|        for (size_t i = base38CharactersInChunk; i > 0; i--)
  ------------------
  |  Branch (131:50): [True: 2.84M, False: 569k]
  ------------------
  132|  2.84M|        {
  133|  2.84M|            uint8_t v      = 0;
  134|  2.84M|            CHIP_ERROR err = decodeChar(base38[decodedBase38Characters + i - 1], v);
  135|       |
  136|  2.84M|            if (err != CHIP_NO_ERROR)
  ------------------
  |  |  482|  2.84M|#define CHIP_NO_ERROR                                          CHIP_ERROR(0, __FILE__, __LINE__)
  ------------------
  |  Branch (136:17): [True: 92, False: 2.84M]
  ------------------
  137|     92|            {
  138|     92|                return err;
  139|     92|            }
  140|       |
  141|  2.84M|            value = value * kRadix + v;
  142|  2.84M|        }
  143|   569k|        decodedBase38Characters += base38CharactersInChunk;
  144|   569k|        base38CharactersNumber -= base38CharactersInChunk;
  145|       |
  146|  2.27M|        for (size_t i = 0; i < bytesInDecodedChunk; i++)
  ------------------
  |  Branch (146:28): [True: 1.70M, False: 569k]
  ------------------
  147|  1.70M|        {
  148|  1.70M|            result.push_back(static_cast<uint8_t>(value));
  149|  1.70M|            value >>= 8;
  150|  1.70M|        }
  151|       |
  152|   569k|        if (value > 0)
  ------------------
  |  Branch (152:13): [True: 34, False: 569k]
  ------------------
  153|     34|        {
  154|       |            // encoded value is too big to represent a correct chunk of size 1, 2 or 3 bytes
  155|     34|            return CHIP_ERROR_INVALID_ARGUMENT;
  ------------------
  |  |  888|     34|#define CHIP_ERROR_INVALID_ARGUMENT                            CHIP_CORE_ERROR(0x2f)
  |  |  ------------------
  |  |  |  |  436|     34|#define CHIP_CORE_ERROR(e) CHIP_SDK_ERROR(::chip::ChipError::SdkPart::kCore, (e))
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|     34|    (::chip::ChipError(::chip::ChipError::SdkErrorConstant<(part), (code)>::value, __FILE__, __LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  156|     34|        }
  157|   569k|    }
  158|     41|    return CHIP_NO_ERROR;
  ------------------
  |  |  482|     41|#define CHIP_NO_ERROR                                          CHIP_ERROR(0, __FILE__, __LINE__)
  ------------------
  159|    179|}
Base38Decode.cpp:_ZN12_GLOBAL__N_110decodeCharEcRh:
   29|  2.84M|{
   30|  2.84M|    static const int kBogus = 255;
   31|       |    // map of base38 charater to numeric value
   32|       |    // subtract 45 from the charater, then index into this array, if possible
   33|  2.84M|    const uint8_t decodes[] = {
   34|  2.84M|        36,     // '-', =45
   35|  2.84M|        37,     // '.', =46
   36|  2.84M|        kBogus, // '/', =47
   37|  2.84M|        0,      // '0', =48
   38|  2.84M|        1,      // '1', =49
   39|  2.84M|        2,      // '2', =50
   40|  2.84M|        3,      // '3', =51
   41|  2.84M|        4,      // '4', =52
   42|  2.84M|        5,      // '5', =53
   43|  2.84M|        6,      // '6', =54
   44|  2.84M|        7,      // '7', =55
   45|  2.84M|        8,      // '8', =56
   46|  2.84M|        9,      // '9', =57
   47|  2.84M|        kBogus, // ':', =58
   48|  2.84M|        kBogus, // ';', =59
   49|  2.84M|        kBogus, // '<', =50
   50|  2.84M|        kBogus, // '=', =61
   51|  2.84M|        kBogus, // '>', =62
   52|  2.84M|        kBogus, // '?', =63
   53|  2.84M|        kBogus, // '@', =64
   54|  2.84M|        10,     // 'A', =65
   55|  2.84M|        11,     // 'B', =66
   56|  2.84M|        12,     // 'C', =67
   57|  2.84M|        13,     // 'D', =68
   58|  2.84M|        14,     // 'E', =69
   59|  2.84M|        15,     // 'F', =70
   60|  2.84M|        16,     // 'G', =71
   61|  2.84M|        17,     // 'H', =72
   62|  2.84M|        18,     // 'I', =73
   63|  2.84M|        19,     // 'J', =74
   64|  2.84M|        20,     // 'K', =75
   65|  2.84M|        21,     // 'L', =76
   66|  2.84M|        22,     // 'M', =77
   67|  2.84M|        23,     // 'N', =78
   68|  2.84M|        24,     // 'O', =79
   69|  2.84M|        25,     // 'P', =80
   70|  2.84M|        26,     // 'Q', =81
   71|  2.84M|        27,     // 'R', =82
   72|  2.84M|        28,     // 'S', =83
   73|  2.84M|        29,     // 'T', =84
   74|  2.84M|        30,     // 'U', =85
   75|  2.84M|        31,     // 'V', =86
   76|  2.84M|        32,     // 'W', =87
   77|  2.84M|        33,     // 'X', =88
   78|  2.84M|        34,     // 'Y', =89
   79|  2.84M|        35,     // 'Z', =90
   80|  2.84M|    };
   81|  2.84M|    if (c < '-' || c > 'Z')
  ------------------
  |  Branch (81:9): [True: 79, False: 2.84M]
  |  Branch (81:20): [True: 12, False: 2.84M]
  ------------------
   82|     91|    {
   83|     91|        return CHIP_ERROR_INVALID_INTEGER_VALUE;
  ------------------
  |  | 1388|     91|#define CHIP_ERROR_INVALID_INTEGER_VALUE                       CHIP_CORE_ERROR(0x8f)
  |  |  ------------------
  |  |  |  |  436|     91|#define CHIP_CORE_ERROR(e) CHIP_SDK_ERROR(::chip::ChipError::SdkPart::kCore, (e))
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|     91|    (::chip::ChipError(::chip::ChipError::SdkErrorConstant<(part), (code)>::value, __FILE__, __LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   84|     91|    }
   85|  2.84M|    uint8_t v = decodes[c - '-'];
   86|  2.84M|    if (v == kBogus)
  ------------------
  |  Branch (86:9): [True: 1, False: 2.84M]
  ------------------
   87|      1|    {
   88|      1|        return CHIP_ERROR_INVALID_INTEGER_VALUE;
  ------------------
  |  | 1388|      1|#define CHIP_ERROR_INVALID_INTEGER_VALUE                       CHIP_CORE_ERROR(0x8f)
  |  |  ------------------
  |  |  |  |  436|      1|#define CHIP_CORE_ERROR(e) CHIP_SDK_ERROR(::chip::ChipError::SdkPart::kCore, (e))
  |  |  |  |  ------------------
  |  |  |  |  |  |  171|      1|    (::chip::ChipError(::chip::ChipError::SdkErrorConstant<(part), (code)>::value, __FILE__, __LINE__))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   89|      1|    }
   90|  2.84M|    value = v;
   91|  2.84M|    return CHIP_NO_ERROR;
  ------------------
  |  |  482|  2.84M|#define CHIP_NO_ERROR                                          CHIP_ERROR(0, __FILE__, __LINE__)
  ------------------
   92|  2.84M|}

LLVMFuzzerTestOneInput:
   15|    179|{
   16|    179|    std::string base38EncodedString(reinterpret_cast<const char *>(data), len);
   17|    179|    std::vector<uint8_t> decodedData;
   18|       |
   19|       |    // Ignoring return value, because in general the data is garbage and won't decode properly.
   20|       |    // We're just testing that the decoder does not crash on the fuzzer-generated inputs.
   21|    179|    chip::base38Decode(base38EncodedString, decodedData);
   22|       |
   23|    179|    return 0;
   24|    179|}

