LLVMFuzzerTestOneInput:
   26|    118|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   27|       |    // Base64Decode expects a null-terminated string.
   28|    118|    char *str = (char *)malloc(size + 1);
   29|    118|    if (!str) {
  ------------------
  |  Branch (29:9): [True: 0, False: 118]
  ------------------
   30|      0|        return 0;
   31|      0|    }
   32|    118|    memcpy(str, data, size);
   33|    118|    str[size] = '\0';
   34|       |
   35|    118|    unsigned char *buffer = NULL;
   36|    118|    size_t length = 0;
   37|       |
   38|       |    // Call the target function
   39|    118|    Base64Decode(str, &buffer, &length);
   40|       |
   41|    118|    if (buffer) {
  ------------------
  |  Branch (41:9): [True: 118, False: 0]
  ------------------
   42|    118|        free(buffer);
   43|    118|    }
   44|    118|    free(str);
   45|    118|    return 0;
   46|    118|}

calcDecodeLength:
  131|    118|size_t calcDecodeLength(const char* b64input) { //Calculates the length of a decoded string
  132|    118|    size_t len = strlen(b64input), padding = 0;
  133|    118|    if (len >= 2 && b64input[len-1] == '=' && b64input[len-2] == '=') //last two chars are =
  ------------------
  |  Branch (133:9): [True: 101, False: 17]
  |  Branch (133:21): [True: 41, False: 60]
  |  Branch (133:47): [True: 25, False: 16]
  ------------------
  134|     25|        padding = 2;
  135|     93|    else if (len >= 1 && b64input[len-1] == '=') //last char is =
  ------------------
  |  Branch (135:14): [True: 92, False: 1]
  |  Branch (135:26): [True: 19, False: 73]
  ------------------
  136|     19|        padding = 1;
  137|       |
  138|    118|    size_t decoded_len = (len*3)/4;
  139|    118|    if (padding > decoded_len) {
  ------------------
  |  Branch (139:9): [True: 4, False: 114]
  ------------------
  140|      4|        return 0;
  141|      4|    }
  142|    114|    return decoded_len - padding;
  143|    118|}
Base64Decode:
  145|    118|int Base64Decode(const char* b64message, unsigned char** buffer, size_t* length) { //Decodes a base64 encoded string
  146|    118|    BIO *bio, *b64;
  147|    118|    int br;
  148|       |
  149|    118|    size_t decodeLen = calcDecodeLength(b64message);
  150|    118|    *buffer = (unsigned char*)malloc(decodeLen + 1);
  151|    118|    if (!*buffer)
  ------------------
  |  Branch (151:9): [True: 0, False: 118]
  ------------------
  152|      0|        return -1;
  153|    118|    (*buffer)[decodeLen] = '\0';
  154|    118|    *length = 0;
  155|       |
  156|    118|    bio = BIO_new_mem_buf(b64message, -1);
  157|    118|    b64 = BIO_new(BIO_f_base64());
  158|    118|    bio = BIO_push(b64, bio);
  159|       |
  160|    118|    BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); //Do not use newlines to flush buffer
  161|    118|    br = BIO_read(bio, *buffer, strlen(b64message));
  162|    118|    BIO_free_all(bio);
  163|       |
  164|    118|    if (br < 0) {
  ------------------
  |  Branch (164:9): [True: 0, False: 118]
  ------------------
  165|      0|        free(*buffer);
  166|      0|        *buffer = NULL;
  167|      0|        return -1;
  168|      0|    }
  169|    118|    *length = (size_t)br;
  170|       |
  171|    118|    return (0); //success
  172|    118|}

