crypto/bn/bn_prime.c:510: error: BUFFER_OVERRUN_L2
  Offset: [0, 18446744073709551615] Size: 256 by call to `BN_mod_word`.
Showing all 11 steps of the trace


crypto/bn/bn_prime.c:510:13: Call
508.       for (i = 1; i < NUMPRIMES; i++) {
509.           /* check that rnd is a prime */
510.           if (BN_mod_word(rnd, (BN_ULONG)primes[i]) <= 1) {
                   ^
511.               if (!BN_add(rnd, rnd, add))
512.                   goto err;

crypto/bn/bn_word.c:13:1: Parameter `w`
  11.   #include "bn_lcl.h"
  12.   
  13. > BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)
  14.   {
  15.   #ifndef BN_LLONG

crypto/bn/bn_word.c:35:15: Call
  33.               return (BN_ULONG)-1;
  34.   
  35.           ret = BN_div_word(tmp, w);
                      ^
  36.           BN_free(tmp);
  37.   

crypto/bn/bn_word.c:61:1: Parameter `w`
    59.   }
    60.   
    61. > BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w)
    62.   {
    63.       BN_ULONG ret = 0;

crypto/bn/bn_word.c:67:5: Assignment
    65.   
    66.       bn_check_top(a);
    67.       w &= BN_MASK2;
              ^
    68.   
    69.       if (!w)

crypto/bn/bn_word.c:76:20: Call
    74.   
    75.       /* normalize input (so bn_div_words doesn't complain) */
    76.       j = BN_BITS2 - BN_num_bits_word(w);
                             ^
    77.       w <<= j;
    78.       if (!BN_lshift(a, a, j))

crypto/bn/bn_lib.c:89:1: <Offset trace>
87.   }
88.   
89. > int BN_num_bits_word(BN_ULONG l)
90.   {
91.       static const unsigned char bits[256] = {

crypto/bn/bn_lib.c:89:1: Parameter `l`
      87.   }
      88.   
      89. > int BN_num_bits_word(BN_ULONG l)
      90.   {
      91.       static const unsigned char bits[256] = {

crypto/bn/bn_lib.c:91:5: <Length trace>
89.   int BN_num_bits_word(BN_ULONG l)
90.   {
91.       static const unsigned char bits[256] = {
          ^
92.           0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
93.           5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,

crypto/bn/bn_lib.c:91:5: Array declaration
      89.   int BN_num_bits_word(BN_ULONG l)
      90.   {
      91.       static const unsigned char bits[256] = {
                ^
      92.           0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
      93.           5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,

crypto/bn/bn_lib.c:114:25: Array access: Offset: [0, 18446744073709551615] Size: 256 by call to `BN_mod_word` 
      112.           if (l & 0xffff000000000000L) {
      113.               if (l & 0xff00000000000000L) {
      114.                   return (bits[(int)(l >> 56)] + 56);
                                     ^
      115.               } else
      116.                   return (bits[(int)(l >> 48)] + 48);

int BN_num_bits_word(BN_ULONG l)
{
    static const unsigned char bits[256] = {
        0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
        5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
        6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
        6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
    };
#if defined(SIXTY_FOUR_BIT_LONG)
    if (l & 0xffffffff00000000L) {
        if (l & 0xffff000000000000L) {
            if (l & 0xff00000000000000L) {
                return (bits[(int)(l >> 56)] + 56);
            } else
                return (bits[(int)(l >> 48)] + 48);
        } else {
            if (l & 0x0000ff0000000000L) {
                return (bits[(int)(l >> 40)] + 40);
            } else
                return (bits[(int)(l >> 32)] + 32);
        }
    } else
#else
# ifdef SIXTY_FOUR_BIT
    if (l & 0xffffffff00000000LL) {
        if (l & 0xffff000000000000LL) {
            if (l & 0xff00000000000000LL) {
                return (bits[(int)(l >> 56)] + 56);
            } else
                return (bits[(int)(l >> 48)] + 48);
        } else {
            if (l & 0x0000ff0000000000LL) {
                return (bits[(int)(l >> 40)] + 40);
            } else
                return (bits[(int)(l >> 32)] + 32);
        }
    } else
# endif
#endif
    {
#if defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
        if (l & 0xffff0000L) {
            if (l & 0xff000000L)
                return (bits[(int)(l >> 24L)] + 24);
            else
                return (bits[(int)(l >> 16L)] + 16);
        } else
#endif
        {
#if defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)
            if (l & 0xff00L)
                return (bits[(int)(l >> 8)] + 8);
            else
#endif
                return (bits[(int)(l)]);
        }
    }
}
['int bn_probable_prime_dh(BIGNUM *rnd, int bits,\n                         const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx)\n{\n    int i, ret = 0;\n    BIGNUM *t1;\n    BN_CTX_start(ctx);\n    if ((t1 = BN_CTX_get(ctx)) == NULL)\n        goto err;\n    if (!BN_rand(rnd, bits, 0, 1))\n        goto err;\n    if (!BN_mod(t1, rnd, add, ctx))\n        goto err;\n    if (!BN_sub(rnd, rnd, t1))\n        goto err;\n    if (rem == NULL) {\n        if (!BN_add_word(rnd, 1))\n            goto err;\n    } else {\n        if (!BN_add(rnd, rnd, rem))\n            goto err;\n    }\n loop:\n    for (i = 1; i < NUMPRIMES; i++) {\n        if (BN_mod_word(rnd, (BN_ULONG)primes[i]) <= 1) {\n            if (!BN_add(rnd, rnd, add))\n                goto err;\n            goto loop;\n        }\n    }\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\n    bn_check_top(rnd);\n    return (ret);\n}', 'BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)\n{\n#ifndef BN_LLONG\n    BN_ULONG ret = 0;\n#else\n    BN_ULLONG ret = 0;\n#endif\n    int i;\n    if (w == 0)\n        return (BN_ULONG)-1;\n#ifndef BN_LLONG\n    if (w > ((BN_ULONG)1 << BN_BITS4)) {\n        BIGNUM *tmp = BN_dup(a);\n        if (tmp == NULL)\n            return (BN_ULONG)-1;\n        ret = BN_div_word(tmp, w);\n        BN_free(tmp);\n        return ret;\n    }\n#endif\n    bn_check_top(a);\n    w &= BN_MASK2;\n    for (i = a->top - 1; i >= 0; i--) {\n#ifndef BN_LLONG\n        ret = ((ret << BN_BITS4) | ((a->d[i] >> BN_BITS4) & BN_MASK2l)) % w;\n        ret = ((ret << BN_BITS4) | (a->d[i] & BN_MASK2l)) % w;\n#else\n        ret = (BN_ULLONG) (((ret << (BN_ULLONG) BN_BITS2) | a->d[i]) %\n                           (BN_ULLONG) w);\n#endif\n    }\n    return ((BN_ULONG)ret);\n}', 'BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w)\n{\n    BN_ULONG ret = 0;\n    int i, j;\n    bn_check_top(a);\n    w &= BN_MASK2;\n    if (!w)\n        return (BN_ULONG)-1;\n    if (a->top == 0)\n        return 0;\n    j = BN_BITS2 - BN_num_bits_word(w);\n    w <<= j;\n    if (!BN_lshift(a, a, j))\n        return (BN_ULONG)-1;\n    for (i = a->top - 1; i >= 0; i--) {\n        BN_ULONG l, d;\n        l = a->d[i];\n        d = bn_div_words(ret, l, w);\n        ret = (l - ((d * w) & BN_MASK2)) & BN_MASK2;\n        a->d[i] = d;\n    }\n    if ((a->top > 0) && (a->d[a->top - 1] == 0))\n        a->top--;\n    ret >>= j;\n    bn_check_top(a);\n    return (ret);\n}', 'int BN_num_bits_word(BN_ULONG l)\n{\n    static const unsigned char bits[256] = {\n        0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,\n        5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,\n        6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n        6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,\n        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,\n        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,\n    };\n#if defined(SIXTY_FOUR_BIT_LONG)\n    if (l & 0xffffffff00000000L) {\n        if (l & 0xffff000000000000L) {\n            if (l & 0xff00000000000000L) {\n                return (bits[(int)(l >> 56)] + 56);\n            } else\n                return (bits[(int)(l >> 48)] + 48);\n        } else {\n            if (l & 0x0000ff0000000000L) {\n                return (bits[(int)(l >> 40)] + 40);\n            } else\n                return (bits[(int)(l >> 32)] + 32);\n        }\n    } else\n#else\n# ifdef SIXTY_FOUR_BIT\n    if (l & 0xffffffff00000000LL) {\n        if (l & 0xffff000000000000LL) {\n            if (l & 0xff00000000000000LL) {\n                return (bits[(int)(l >> 56)] + 56);\n            } else\n                return (bits[(int)(l >> 48)] + 48);\n        } else {\n            if (l & 0x0000ff0000000000LL) {\n                return (bits[(int)(l >> 40)] + 40);\n            } else\n                return (bits[(int)(l >> 32)] + 32);\n        }\n    } else\n# endif\n#endif\n    {\n#if defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)\n        if (l & 0xffff0000L) {\n            if (l & 0xff000000L)\n                return (bits[(int)(l >> 24L)] + 24);\n            else\n                return (bits[(int)(l >> 16L)] + 16);\n        } else\n#endif\n        {\n#if defined(THIRTY_TWO_BIT) || defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)\n            if (l & 0xff00L)\n                return (bits[(int)(l >> 8)] + 8);\n            else\n#endif\n                return (bits[(int)(l)]);\n        }\n    }\n}']