crypto/txt_db/txt_db.c:217: error: BUFFER_OVERRUN_L3
  Offset: [16, +oo] Size: [1, +oo] by call to `lh_insert`.
Showing all 14 steps of the trace


crypto/txt_db/txt_db.c:208:44: Call
206.       }
207.       /* FIXME: we lose type checking at this point */
208.       if ((idx = (LHASH_OF(OPENSSL_STRING) *)lh_new(hash, cmp)) == NULL) {
                                                  ^
209.           db->error = DB_ERROR_MALLOC;
210.           return (0);

crypto/lhash/lhash.c:124:5: Assignment
  122.       ret->hash = ((h == NULL) ? (LHASH_HASH_FN_TYPE)lh_strhash : h);
  123.       ret->num_nodes = MIN_NODES / 2;
  124.       ret->num_alloc_nodes = MIN_NODES;
             ^
  125.       ret->pmax = MIN_NODES / 2;
  126.       ret->up_load = UP_LOAD;

crypto/txt_db/txt_db.c:217:18: Call
215.           if ((qual != NULL) && (qual(r) == 0))
216.               continue;
217.           if ((r = lh_OPENSSL_STRING_insert(idx, r)) != NULL) {
                        ^
218.               db->error = DB_ERROR_INDEX_CLASH;
219.               db->arg1 = sk_OPENSSL_PSTRING_find(db->data, r);

crypto/lhash/lhash.c:156:1: Parameter `*lh->b`
  154.   }
  155.   
  156. > void *lh_insert(_LHASH *lh, void *data)
  157.   {
  158.       unsigned long hash;

crypto/lhash/lhash.c:164:9: Call
  162.       lh->error = 0;
  163.       if (lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes))
  164.           expand(lh);
                 ^
  165.   
  166.       rn = getrn(lh, data, &hash);

crypto/lhash/lhash.c:279:1: <Offset trace>
277.   }
278.   
279. > static void expand(_LHASH *lh)
280.   {
281.       LHASH_NODE **n, **n1, **n2, *np;

crypto/lhash/lhash.c:279:1: Parameter `lh->num_alloc_nodes`
    277.   }
    278.   
    279. > static void expand(_LHASH *lh)
    280.   {
    281.       LHASH_NODE **n, **n1, **n2, *np;

crypto/lhash/lhash.c:305:9: Assignment
    303.   
    304.       if ((lh->p) >= lh->pmax) {
    305.           j = (int)lh->num_alloc_nodes * 2;
                   ^
    306.           n = OPENSSL_realloc(lh->b, (int)(sizeof(LHASH_NODE *) * j));
    307.           if (n == NULL) {

crypto/lhash/lhash.c:279:1: <Length trace>
277.   }
278.   
279. > static void expand(_LHASH *lh)
280.   {
281.       LHASH_NODE **n, **n1, **n2, *np;

crypto/lhash/lhash.c:279:1: Parameter `*lh->b`
    277.   }
    278.   
    279. > static void expand(_LHASH *lh)
    280.   {
    281.       LHASH_NODE **n, **n1, **n2, *np;

crypto/lhash/lhash.c:306:13: Call
    304.       if ((lh->p) >= lh->pmax) {
    305.           j = (int)lh->num_alloc_nodes * 2;
    306.           n = OPENSSL_realloc(lh->b, (int)(sizeof(LHASH_NODE *) * j));
                       ^
    307.           if (n == NULL) {
    308.               /* fputs("realloc error in lhash",stderr); */

crypto/mem.c:173:9: Assignment
      171.       if (num == 0) {
      172.           CRYPTO_free(str);
      173.           return NULL;
                     ^
      174.       }
      175.   

crypto/lhash/lhash.c:306:9: Assignment
    304.       if ((lh->p) >= lh->pmax) {
    305.           j = (int)lh->num_alloc_nodes * 2;
    306.           n = OPENSSL_realloc(lh->b, (int)(sizeof(LHASH_NODE *) * j));
                   ^
    307.           if (n == NULL) {
    308.               /* fputs("realloc error in lhash",stderr); */

crypto/lhash/lhash.c:314:13: Array access: Offset: [16, +oo] Size: [1, +oo] by call to `lh_insert` 
    312.           }
    313.           for (i = (int)lh->num_alloc_nodes; i < j; i++) /* 26/02/92 eay */
    314.               n[i] = NULL;        /* 02/03/92 eay */
                       ^
    315.           lh->pmax = lh->num_alloc_nodes;
    316.           lh->num_alloc_nodes = j;

static void expand(_LHASH *lh)
{
    LHASH_NODE **n, **n1, **n2, *np;
    unsigned int p, i, j;
    unsigned long hash, nni;
    lh->num_nodes++;
    lh->num_expands++;
    p = (int)lh->p++;
    n1 = &(lh->b[p]);
    n2 = &(lh->b[p + (int)lh->pmax]);
    *n2 = NULL;
    nni = lh->num_alloc_nodes;
    for (np = *n1; np != NULL;) {
        hash = np->hash;
        if ((hash % nni) != p) {
            *n1 = (*n1)->next;
            np->next = *n2;
            *n2 = np;
        } else
            n1 = &((*n1)->next);
        np = *n1;
    }
    if ((lh->p) >= lh->pmax) {
        j = (int)lh->num_alloc_nodes * 2;
        n = OPENSSL_realloc(lh->b, (int)(sizeof(LHASH_NODE *) * j));
        if (n == NULL) {
            lh->error++;
            lh->p = 0;
            return;
        }
        for (i = (int)lh->num_alloc_nodes; i < j; i++)
            n[i] = NULL;
        lh->pmax = lh->num_alloc_nodes;
        lh->num_alloc_nodes = j;
        lh->num_expand_reallocs++;
        lh->p = 0;
        lh->b = n;
    }
}
['int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *),\n                        LHASH_HASH_FN_TYPE hash, LHASH_COMP_FN_TYPE cmp)\n{\n    LHASH_OF(OPENSSL_STRING) *idx;\n    OPENSSL_STRING *r;\n    int i, n;\n    if (field >= db->num_fields) {\n        db->error = DB_ERROR_INDEX_OUT_OF_RANGE;\n        return (0);\n    }\n    if ((idx = (LHASH_OF(OPENSSL_STRING) *)lh_new(hash, cmp)) == NULL) {\n        db->error = DB_ERROR_MALLOC;\n        return (0);\n    }\n    n = sk_OPENSSL_PSTRING_num(db->data);\n    for (i = 0; i < n; i++) {\n        r = sk_OPENSSL_PSTRING_value(db->data, i);\n        if ((qual != NULL) && (qual(r) == 0))\n            continue;\n        if ((r = lh_OPENSSL_STRING_insert(idx, r)) != NULL) {\n            db->error = DB_ERROR_INDEX_CLASH;\n            db->arg1 = sk_OPENSSL_PSTRING_find(db->data, r);\n            db->arg2 = i;\n            lh_OPENSSL_STRING_free(idx);\n            return (0);\n        }\n    }\n    lh_OPENSSL_STRING_free(db->index[field]);\n    db->index[field] = idx;\n    db->qual[field] = qual;\n    return (1);\n}', '_LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c)\n{\n    _LHASH *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)\n        goto err0;\n    if ((ret->b = OPENSSL_zalloc(sizeof(*ret->b) * MIN_NODES)) == NULL)\n        goto err1;\n    ret->comp = ((c == NULL) ? (LHASH_COMP_FN_TYPE)strcmp : c);\n    ret->hash = ((h == NULL) ? (LHASH_HASH_FN_TYPE)lh_strhash : h);\n    ret->num_nodes = MIN_NODES / 2;\n    ret->num_alloc_nodes = MIN_NODES;\n    ret->pmax = MIN_NODES / 2;\n    ret->up_load = UP_LOAD;\n    ret->down_load = DOWN_LOAD;\n    return (ret);\n err1:\n    OPENSSL_free(ret);\n err0:\n    return (NULL);\n}', 'void *lh_insert(_LHASH *lh, void *data)\n{\n    unsigned long hash;\n    LHASH_NODE *nn, **rn;\n    void *ret;\n    lh->error = 0;\n    if (lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes))\n        expand(lh);\n    rn = getrn(lh, data, &hash);\n    if (*rn == NULL) {\n        if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {\n            lh->error++;\n            return (NULL);\n        }\n        nn->data = data;\n        nn->next = NULL;\n        nn->hash = hash;\n        *rn = nn;\n        ret = NULL;\n        lh->num_insert++;\n        lh->num_items++;\n    } else {\n        ret = (*rn)->data;\n        (*rn)->data = data;\n        lh->num_replace++;\n    }\n    return (ret);\n}', 'static void expand(_LHASH *lh)\n{\n    LHASH_NODE **n, **n1, **n2, *np;\n    unsigned int p, i, j;\n    unsigned long hash, nni;\n    lh->num_nodes++;\n    lh->num_expands++;\n    p = (int)lh->p++;\n    n1 = &(lh->b[p]);\n    n2 = &(lh->b[p + (int)lh->pmax]);\n    *n2 = NULL;\n    nni = lh->num_alloc_nodes;\n    for (np = *n1; np != NULL;) {\n        hash = np->hash;\n        if ((hash % nni) != p) {\n            *n1 = (*n1)->next;\n            np->next = *n2;\n            *n2 = np;\n        } else\n            n1 = &((*n1)->next);\n        np = *n1;\n    }\n    if ((lh->p) >= lh->pmax) {\n        j = (int)lh->num_alloc_nodes * 2;\n        n = OPENSSL_realloc(lh->b, (int)(sizeof(LHASH_NODE *) * j));\n        if (n == NULL) {\n            lh->error++;\n            lh->p = 0;\n            return;\n        }\n        for (i = (int)lh->num_alloc_nodes; i < j; i++)\n            n[i] = NULL;\n        lh->pmax = lh->num_alloc_nodes;\n        lh->num_alloc_nodes = j;\n        lh->num_expand_reallocs++;\n        lh->p = 0;\n        lh->b = n;\n    }\n}', 'void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)\n{\n    if (str == NULL)\n        return CRYPTO_malloc(num, file, line);\n    if (num == 0) {\n        CRYPTO_free(str);\n        return NULL;\n    }\n    allow_customize = 0;\n#ifdef CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        void *ret;\n        CRYPTO_mem_debug_realloc(str, NULL, num, 0, file, line);\n        ret = realloc(str, num);\n        CRYPTO_mem_debug_realloc(str, ret, num, 1, file, line);\n        return ret;\n    }\n#else\n    (void)file;\n    (void)line;\n#endif\n    return realloc(str, num);\n}']