apps/testdsa.h:60: error: BUFFER_OVERRUN_L3
  Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [0, 8388607] by call to `BN_bin2bn`.
Showing all 13 steps of the trace


apps/testdsa.h:59:16: Call
57.       if ((dsa = DSA_new()) == NULL)
58.           return (NULL);
59.       priv_key = BN_bin2bn(dsa512_priv, sizeof(dsa512_priv), NULL);
                     ^
60.       pub_key = BN_bin2bn(dsa512_pub, sizeof(dsa512_pub), NULL);
61.       p = BN_bin2bn(dsa512_p, sizeof(dsa512_p), NULL);

crypto/bn/bn_lib.c:475:1: Parameter `*ret->d`
  473.   }
  474.   
  475. > BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
  476.   {
  477.       unsigned int i, m;

apps/testdsa.h:60:15: Call
58.           return (NULL);
59.       priv_key = BN_bin2bn(dsa512_priv, sizeof(dsa512_priv), NULL);
60.       pub_key = BN_bin2bn(dsa512_pub, sizeof(dsa512_pub), NULL);
                    ^
61.       p = BN_bin2bn(dsa512_p, sizeof(dsa512_p), NULL);
62.       q = BN_bin2bn(dsa512_q, sizeof(dsa512_q), NULL);

crypto/bn/bn_lib.c:475:1: Parameter `*ret->d`
  473.   }
  474.   
  475. > BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
  476.   {
  477.       unsigned int i, m;

crypto/bn/bn_lib.c:497:9: Call
  495.       i = ((n - 1) / BN_BYTES) + 1;
  496.       m = ((n - 1) % (BN_BYTES));
  497.       if (bn_wexpand(ret, (int)i) == NULL) {
                 ^
  498.           BN_free(bn);
  499.           return NULL;

crypto/bn/bn_lib.c:1014:1: Parameter `*a->d`
    1012.   }
    1013.   
    1014. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
    1015.   {
    1016.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_lib.c:1016:37: Call
    1014.   BIGNUM *bn_wexpand(BIGNUM *a, int words)
    1015.   {
    1016.       return (words <= a->dmax) ? a : bn_expand2(a, words);
                                                ^
    1017.   }
    1018.   

crypto/bn/bn_lib.c:323:1: Parameter `*b->d`
      321.    */
      322.   
      323. > BIGNUM *bn_expand2(BIGNUM *b, int words)
      324.   {
      325.       bn_check_top(b);

crypto/bn/bn_lib.c:328:23: Call
      326.   
      327.       if (words > b->dmax) {
      328.           BN_ULONG *a = bn_expand_internal(b, words);
                                   ^
      329.           if (!a)
      330.               return NULL;

crypto/bn/bn_lib.c:246:1: <Length trace>
244.   /* This is used by bn_expand2() */
245.   /* The caller MUST check that words > b->dmax before calling this */
246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
247.   {
248.       BN_ULONG *A, *a = NULL;

crypto/bn/bn_lib.c:246:1: Parameter `*b->d`
        244.   /* This is used by bn_expand2() */
        245.   /* The caller MUST check that words > b->dmax before calling this */
        246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
        247.   {
        248.       BN_ULONG *A, *a = NULL;

crypto/bn/bn_lib.c:272:5: Assignment
        270.   
        271.   #if 1
        272.       B = b->d;
                   ^
        273.       /* Check if the previous number needs to be copied */
        274.       if (B != NULL) {

crypto/bn/bn_lib.c:289:18: Array access: Offset: [3, +oo] (⇐ [0, +oo] + 3) Size: [0, 8388607] by call to `BN_bin2bn` 
        287.               a1 = B[1];
        288.               a2 = B[2];
        289.               a3 = B[3];
                                ^
        290.               A[0] = a0;
        291.               A[1] = a1;

static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
{
    BN_ULONG *A, *a = NULL;
    const BN_ULONG *B;
    int i;
    bn_check_top(b);
    if (words > (INT_MAX / (4 * BN_BITS2))) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG);
        return NULL;
    }
    if (BN_get_flags(b, BN_FLG_STATIC_DATA)) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
        return (NULL);
    }
    if (BN_get_flags(b,BN_FLG_SECURE))
        a = A = OPENSSL_secure_zalloc(words * sizeof(*a));
    else
        a = A = OPENSSL_zalloc(words * sizeof(*a));
    if (A == NULL) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);
        return (NULL);
    }
#if 1
    B = b->d;
    if (B != NULL) {
        for (i = b->top >> 2; i > 0; i--, A += 4, B += 4) {
            BN_ULONG a0, a1, a2, a3;
            a0 = B[0];
            a1 = B[1];
            a2 = B[2];
            a3 = B[3];
            A[0] = a0;
            A[1] = a1;
            A[2] = a2;
            A[3] = a3;
        }
        switch (b->top & 3) {
        case 3:
            A[2] = B[2];
        case 2:
            A[1] = B[1];
        case 1:
            A[0] = B[0];
        case 0:
            ;
        }
    }
#else
    memset(A, 0, sizeof(*A) * words);
    memcpy(A, b->d, sizeof(b->d[0]) * b->top);
#endif
    return (a);
}
['DSA *get_dsa512()\n{\n    DSA *dsa;\n    BIGNUM *priv_key, *pub_key, *p, *q, *g;\n    if ((dsa = DSA_new()) == NULL)\n        return (NULL);\n    priv_key = BN_bin2bn(dsa512_priv, sizeof(dsa512_priv), NULL);\n    pub_key = BN_bin2bn(dsa512_pub, sizeof(dsa512_pub), NULL);\n    p = BN_bin2bn(dsa512_p, sizeof(dsa512_p), NULL);\n    q = BN_bin2bn(dsa512_q, sizeof(dsa512_q), NULL);\n    g = BN_bin2bn(dsa512_g, sizeof(dsa512_g), NULL);\n    if ((priv_key == NULL) || (pub_key == NULL) || (p == NULL) || (q == NULL)\n            || (g == NULL)) {\n        goto err;\n    }\n    if (!DSA_set0_pqg(dsa, p, q, g))\n        goto err;\n    p = q = g = NULL;\n    if (!DSA_set0_key(dsa, pub_key, priv_key))\n        goto err;\n    return dsa;\n err:\n    DSA_free(dsa);\n    BN_free(priv_key);\n    BN_free(pub_key);\n    BN_free(p);\n    BN_free(q);\n    BN_free(g);\n    return NULL;\n}', 'BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)\n{\n    unsigned int i, m;\n    unsigned int n;\n    BN_ULONG l;\n    BIGNUM *bn = NULL;\n    if (ret == NULL)\n        ret = bn = BN_new();\n    if (ret == NULL)\n        return (NULL);\n    bn_check_top(ret);\n    for ( ; len > 0 && *s == 0; s++, len--)\n        continue;\n    n = len;\n    if (n == 0) {\n        ret->top = 0;\n        return (ret);\n    }\n    i = ((n - 1) / BN_BYTES) + 1;\n    m = ((n - 1) % (BN_BYTES));\n    if (bn_wexpand(ret, (int)i) == NULL) {\n        BN_free(bn);\n        return NULL;\n    }\n    ret->top = i;\n    ret->neg = 0;\n    l = 0;\n    while (n--) {\n        l = (l << 8L) | *(s++);\n        if (m-- == 0) {\n            ret->d[--i] = l;\n            l = 0;\n            m = BN_BYTES - 1;\n        }\n    }\n    bn_correct_top(ret);\n    return (ret);\n}', 'BIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}', 'BIGNUM *bn_expand2(BIGNUM *b, int words)\n{\n    bn_check_top(b);\n    if (words > b->dmax) {\n        BN_ULONG *a = bn_expand_internal(b, words);\n        if (!a)\n            return NULL;\n        if (b->d) {\n            OPENSSL_cleanse(b->d, b->dmax * sizeof(b->d[0]));\n            bn_free_d(b);\n        }\n        b->d = a;\n        b->dmax = words;\n    }\n    bn_check_top(b);\n    return b;\n}', 'static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)\n{\n    BN_ULONG *A, *a = NULL;\n    const BN_ULONG *B;\n    int i;\n    bn_check_top(b);\n    if (words > (INT_MAX / (4 * BN_BITS2))) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG);\n        return NULL;\n    }\n    if (BN_get_flags(b, BN_FLG_STATIC_DATA)) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);\n        return (NULL);\n    }\n    if (BN_get_flags(b,BN_FLG_SECURE))\n        a = A = OPENSSL_secure_zalloc(words * sizeof(*a));\n    else\n        a = A = OPENSSL_zalloc(words * sizeof(*a));\n    if (A == NULL) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n#if 1\n    B = b->d;\n    if (B != NULL) {\n        for (i = b->top >> 2; i > 0; i--, A += 4, B += 4) {\n            BN_ULONG a0, a1, a2, a3;\n            a0 = B[0];\n            a1 = B[1];\n            a2 = B[2];\n            a3 = B[3];\n            A[0] = a0;\n            A[1] = a1;\n            A[2] = a2;\n            A[3] = a3;\n        }\n        switch (b->top & 3) {\n        case 3:\n            A[2] = B[2];\n        case 2:\n            A[1] = B[1];\n        case 1:\n            A[0] = B[0];\n        case 0:\n            ;\n        }\n    }\n#else\n    memset(A, 0, sizeof(*A) * words);\n    memcpy(A, b->d, sizeof(b->d[0]) * b->top);\n#endif\n    return (a);\n}']