test/bntest.c:2183: error: NULL_DEREFERENCE
  pointer `null` is dereferenced by call to `BN_mod_exp()` at line 2183, column 10.
Showing all 83 steps of the trace


test/bntest.c:2172:1: start of procedure test_expmodzero()
2170.   }
2171.   
2172. > static int test_expmodzero(void)
2173.   {
2174.       BIGNUM *a = NULL, *r = NULL, *zero = NULL;

test/bntest.c:2174:5: 
2172.   static int test_expmodzero(void)
2173.   {
2174. >     BIGNUM *a = NULL, *r = NULL, *zero = NULL;
2175.       int st = 0;
2176.   

test/bntest.c:2175:5: 
2173.   {
2174.       BIGNUM *a = NULL, *r = NULL, *zero = NULL;
2175. >     int st = 0;
2176.   
2177.       if (!TEST_ptr(zero = BN_new())

test/bntest.c:2177:10: Skipping BN_new(): empty list of specs
2175.       int st = 0;
2176.   
2177.       if (!TEST_ptr(zero = BN_new())
                 ^
2178.               || !TEST_ptr(a = BN_new())
2179.               || !TEST_ptr(r = BN_new()))

test/testutil/tests.c:252:1: start of procedure test_ptr()
  250.   }
  251.   
  252. > int test_ptr(const char *file, int line, const char *s, const void *p)
  253.   {
  254.       if (p != NULL)

test/testutil/tests.c:254:9: Taking true branch
  252.   int test_ptr(const char *file, int line, const char *s, const void *p)
  253.   {
  254.       if (p != NULL)
                 ^
  255.           return 1;
  256.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:255:9: 
  253.   {
  254.       if (p != NULL)
  255. >         return 1;
  256.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  257.       return 0;

test/testutil/tests.c:258:1: return from a call to test_ptr
  256.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  257.       return 0;
  258. > }
  259.   
  260.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:2177:10: Taking false branch
2175.       int st = 0;
2176.   
2177.       if (!TEST_ptr(zero = BN_new())
                 ^
2178.               || !TEST_ptr(a = BN_new())
2179.               || !TEST_ptr(r = BN_new()))

test/bntest.c:2178:17: Skipping BN_new(): empty list of specs
2176.   
2177.       if (!TEST_ptr(zero = BN_new())
2178.               || !TEST_ptr(a = BN_new())
                        ^
2179.               || !TEST_ptr(r = BN_new()))
2180.           goto err;

test/testutil/tests.c:252:1: start of procedure test_ptr()
  250.   }
  251.   
  252. > int test_ptr(const char *file, int line, const char *s, const void *p)
  253.   {
  254.       if (p != NULL)

test/testutil/tests.c:254:9: Taking true branch
  252.   int test_ptr(const char *file, int line, const char *s, const void *p)
  253.   {
  254.       if (p != NULL)
                 ^
  255.           return 1;
  256.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:255:9: 
  253.   {
  254.       if (p != NULL)
  255. >         return 1;
  256.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  257.       return 0;

test/testutil/tests.c:258:1: return from a call to test_ptr
  256.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  257.       return 0;
  258. > }
  259.   
  260.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:2178:17: Taking false branch
2176.   
2177.       if (!TEST_ptr(zero = BN_new())
2178.               || !TEST_ptr(a = BN_new())
                        ^
2179.               || !TEST_ptr(r = BN_new()))
2180.           goto err;

test/bntest.c:2179:17: Skipping BN_new(): empty list of specs
2177.       if (!TEST_ptr(zero = BN_new())
2178.               || !TEST_ptr(a = BN_new())
2179.               || !TEST_ptr(r = BN_new()))
                        ^
2180.           goto err;
2181.       BN_zero(zero);

test/testutil/tests.c:252:1: start of procedure test_ptr()
  250.   }
  251.   
  252. > int test_ptr(const char *file, int line, const char *s, const void *p)
  253.   {
  254.       if (p != NULL)

test/testutil/tests.c:254:9: Taking true branch
  252.   int test_ptr(const char *file, int line, const char *s, const void *p)
  253.   {
  254.       if (p != NULL)
                 ^
  255.           return 1;
  256.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:255:9: 
  253.   {
  254.       if (p != NULL)
  255. >         return 1;
  256.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  257.       return 0;

test/testutil/tests.c:258:1: return from a call to test_ptr
  256.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  257.       return 0;
  258. > }
  259.   
  260.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:2179:17: Taking false branch
2177.       if (!TEST_ptr(zero = BN_new())
2178.               || !TEST_ptr(a = BN_new())
2179.               || !TEST_ptr(r = BN_new()))
                        ^
2180.           goto err;
2181.       BN_zero(zero);

test/bntest.c:2181:5: Skipping BN_set_word(): empty list of specs
2179.               || !TEST_ptr(r = BN_new()))
2180.           goto err;
2181.       BN_zero(zero);
            ^
2182.   
2183.       if (!TEST_true(BN_mod_exp(r, a, zero, BN_value_one(), NULL))

test/bntest.c:2183:10: 
2181.       BN_zero(zero);
2182.   
2183. >     if (!TEST_true(BN_mod_exp(r, a, zero, BN_value_one(), NULL))
2184.               || !TEST_BN_eq_zero(r)
2185.               || !TEST_true(BN_mod_exp_mont(r, a, zero, BN_value_one(),

crypto/bn/bn_lib.c:81:1: start of procedure BN_value_one()
  79.   #endif
  80.   
  81. > const BIGNUM *BN_value_one(void)
  82.   {
  83.       static const BN_ULONG data_one = 1L;

crypto/bn/bn_lib.c:83:5: 
  81.   const BIGNUM *BN_value_one(void)
  82.   {
  83. >     static const BN_ULONG data_one = 1L;
  84.       static const BIGNUM const_one =
  85.           { (BN_ULONG *)&data_one, 1, 1, 0, BN_FLG_STATIC_DATA };

crypto/bn/bn_lib.c:84:5: 
  82.   {
  83.       static const BN_ULONG data_one = 1L;
  84. >     static const BIGNUM const_one =
  85.           { (BN_ULONG *)&data_one, 1, 1, 0, BN_FLG_STATIC_DATA };
  86.   

crypto/bn/bn_lib.c:87:5: 
  85.           { (BN_ULONG *)&data_one, 1, 1, 0, BN_FLG_STATIC_DATA };
  86.   
  87. >     return &const_one;
  88.   }
  89.   

crypto/bn/bn_lib.c:88:1: return from a call to BN_value_one
  86.   
  87.       return &const_one;
  88. > }
  89.   
  90.   int BN_num_bits_word(BN_ULONG l)

crypto/bn/bn_exp.c:89:1: start of procedure BN_mod_exp()
  87.   }
  88.   
  89. > int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m,
  90.                  BN_CTX *ctx)
  91.   {

crypto/bn/bn_exp.c:134:9: 
  132.   
  133.   #ifdef MONT_MUL_MOD
  134. >     if (BN_is_odd(m)) {
  135.   # ifdef MONT_EXP_WORD
  136.           if (a->top == 1 && !a->neg

crypto/bn/bn_lib.c:920:1: start of procedure BN_is_odd()
    918.   }
    919.   
    920. > int BN_is_odd(const BIGNUM *a)
    921.   {
    922.       return (a->top > 0) && (a->d[0] & 1);

crypto/bn/bn_lib.c:922:13: Condition is true
    920.   int BN_is_odd(const BIGNUM *a)
    921.   {
    922.       return (a->top > 0) && (a->d[0] & 1);
                       ^
    923.   }
    924.   

crypto/bn/bn_lib.c:922:29: Condition is false
    920.   int BN_is_odd(const BIGNUM *a)
    921.   {
    922.       return (a->top > 0) && (a->d[0] & 1);
                                       ^
    923.   }
    924.   

crypto/bn/bn_lib.c:922:12: 
    920.   int BN_is_odd(const BIGNUM *a)
    921.   {
    922. >     return (a->top > 0) && (a->d[0] & 1);
    923.   }
    924.   

crypto/bn/bn_lib.c:922:5: 
    920.   int BN_is_odd(const BIGNUM *a)
    921.   {
    922. >     return (a->top > 0) && (a->d[0] & 1);
    923.   }
    924.   

crypto/bn/bn_lib.c:923:1: return from a call to BN_is_odd
    921.   {
    922.       return (a->top > 0) && (a->d[0] & 1);
    923. > }
    924.   
    925.   int BN_is_negative(const BIGNUM *a)

crypto/bn/bn_exp.c:134:9: Taking false branch
  132.   
  133.   #ifdef MONT_MUL_MOD
  134.       if (BN_is_odd(m)) {
                 ^
  135.   # ifdef MONT_EXP_WORD
  136.           if (a->top == 1 && !a->neg

crypto/bn/bn_exp.c:149:9: 
  147.   #ifdef RECP_MUL_MOD
  148.       {
  149. >         ret = BN_mod_exp_recp(r, a, p, m, ctx);
  150.       }
  151.   #else

crypto/bn/bn_exp.c:161:1: start of procedure BN_mod_exp_recp()
    159.   }
    160.   
    161. > int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
    162.                       const BIGNUM *m, BN_CTX *ctx)
    163.   {

crypto/bn/bn_exp.c:164:5: 
    162.                       const BIGNUM *m, BN_CTX *ctx)
    163.   {
    164. >     int i, j, bits, ret = 0, wstart, wend, window, wvalue;
    165.       int start = 1;
    166.       BIGNUM *aa;

crypto/bn/bn_exp.c:165:5: 
    163.   {
    164.       int i, j, bits, ret = 0, wstart, wend, window, wvalue;
    165. >     int start = 1;
    166.       BIGNUM *aa;
    167.       /* Table of variables obtained from 'ctx' */

crypto/bn/bn_exp.c:171:9: 
    169.       BN_RECP_CTX recp;
    170.   
    171. >     if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0
    172.               || BN_get_flags(a, BN_FLG_CONSTTIME) != 0
    173.               || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {

crypto/bn/bn_lib.c:971:1: start of procedure BN_get_flags()
      969.   }
      970.   
      971. > int BN_get_flags(const BIGNUM *b, int n)
      972.   {
      973.       return b->flags & n;

crypto/bn/bn_lib.c:973:5: 
      971.   int BN_get_flags(const BIGNUM *b, int n)
      972.   {
      973. >     return b->flags & n;
      974.   }
      975.   

crypto/bn/bn_lib.c:974:1: return from a call to BN_get_flags
      972.   {
      973.       return b->flags & n;
      974. > }
      975.   
      976.   /* Populate a BN_GENCB structure with an "old"-style callback */

crypto/bn/bn_exp.c:171:9: Taking false branch
    169.       BN_RECP_CTX recp;
    170.   
    171.       if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0
                   ^
    172.               || BN_get_flags(a, BN_FLG_CONSTTIME) != 0
    173.               || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {

crypto/bn/bn_exp.c:172:16: 
    170.   
    171.       if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0
    172. >             || BN_get_flags(a, BN_FLG_CONSTTIME) != 0
    173.               || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {
    174.           /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */

crypto/bn/bn_lib.c:971:1: start of procedure BN_get_flags()
      969.   }
      970.   
      971. > int BN_get_flags(const BIGNUM *b, int n)
      972.   {
      973.       return b->flags & n;

crypto/bn/bn_lib.c:973:5: 
      971.   int BN_get_flags(const BIGNUM *b, int n)
      972.   {
      973. >     return b->flags & n;
      974.   }
      975.   

crypto/bn/bn_lib.c:974:1: return from a call to BN_get_flags
      972.   {
      973.       return b->flags & n;
      974. > }
      975.   
      976.   /* Populate a BN_GENCB structure with an "old"-style callback */

crypto/bn/bn_exp.c:172:16: Taking false branch
    170.   
    171.       if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0
    172.               || BN_get_flags(a, BN_FLG_CONSTTIME) != 0
                          ^
    173.               || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {
    174.           /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */

crypto/bn/bn_exp.c:173:16: 
    171.       if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0
    172.               || BN_get_flags(a, BN_FLG_CONSTTIME) != 0
    173. >             || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {
    174.           /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */
    175.           BNerr(BN_F_BN_MOD_EXP_RECP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);

crypto/bn/bn_lib.c:971:1: start of procedure BN_get_flags()
      969.   }
      970.   
      971. > int BN_get_flags(const BIGNUM *b, int n)
      972.   {
      973.       return b->flags & n;

crypto/bn/bn_lib.c:973:5: 
      971.   int BN_get_flags(const BIGNUM *b, int n)
      972.   {
      973. >     return b->flags & n;
      974.   }
      975.   

crypto/bn/bn_lib.c:974:1: return from a call to BN_get_flags
      972.   {
      973.       return b->flags & n;
      974. > }
      975.   
      976.   /* Populate a BN_GENCB structure with an "old"-style callback */

crypto/bn/bn_exp.c:173:16: Taking false branch
    171.       if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0
    172.               || BN_get_flags(a, BN_FLG_CONSTTIME) != 0
    173.               || BN_get_flags(m, BN_FLG_CONSTTIME) != 0) {
                          ^
    174.           /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */
    175.           BNerr(BN_F_BN_MOD_EXP_RECP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);

crypto/bn/bn_exp.c:179:5: 
    177.       }
    178.   
    179. >     bits = BN_num_bits(p);
    180.       if (bits == 0) {
    181.           /* x**0 mod 1, or x**0 mod -1 is still zero. */

crypto/bn/bn_lib.c:165:1: start of procedure BN_num_bits()
      163.   }
      164.   
      165. > int BN_num_bits(const BIGNUM *a)
      166.   {
      167.       int i = a->top - 1;

crypto/bn/bn_lib.c:167:5: 
      165.   int BN_num_bits(const BIGNUM *a)
      166.   {
      167. >     int i = a->top - 1;
      168.       bn_check_top(a);
      169.   

crypto/bn/bn_lib.c:170:9: Taking false branch
      168.       bn_check_top(a);
      169.   
      170.       if (a->flags & BN_FLG_CONSTTIME) {
                     ^
      171.           /*
      172.            * We assume that BIGNUMs flagged as CONSTTIME have also been expanded

crypto/bn/bn_lib.c:183:9: 
      181.       }
      182.   
      183. >     if (BN_is_zero(a))
      184.           return 0;
      185.   

crypto/bn/bn_lib.c:905:1: start of procedure BN_is_zero()
        903.   }
        904.   
        905. > int BN_is_zero(const BIGNUM *a)
        906.   {
        907.       return a->top == 0;

crypto/bn/bn_lib.c:907:12: Condition is true
        905.   int BN_is_zero(const BIGNUM *a)
        906.   {
        907.       return a->top == 0;
                          ^
        908.   }
        909.   

crypto/bn/bn_lib.c:907:5: 
        905.   int BN_is_zero(const BIGNUM *a)
        906.   {
        907. >     return a->top == 0;
        908.   }
        909.   

crypto/bn/bn_lib.c:908:1: return from a call to BN_is_zero
        906.   {
        907.       return a->top == 0;
        908. > }
        909.   
        910.   int BN_is_one(const BIGNUM *a)

crypto/bn/bn_lib.c:183:9: Taking true branch
      181.       }
      182.   
      183.       if (BN_is_zero(a))
                     ^
      184.           return 0;
      185.   

crypto/bn/bn_lib.c:184:9: 
      182.   
      183.       if (BN_is_zero(a))
      184. >         return 0;
      185.   
      186.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));

crypto/bn/bn_lib.c:187:1: return from a call to BN_num_bits
      185.   
      186.       return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));
      187. > }
      188.   
      189.   static void bn_free_d(BIGNUM *a, int clear)

crypto/bn/bn_exp.c:180:9: Taking true branch
    178.   
    179.       bits = BN_num_bits(p);
    180.       if (bits == 0) {
                   ^
    181.           /* x**0 mod 1, or x**0 mod -1 is still zero. */
    182.           if (BN_abs_is_word(m, 1)) {

crypto/bn/bn_exp.c:182:13: 
    180.       if (bits == 0) {
    181.           /* x**0 mod 1, or x**0 mod -1 is still zero. */
    182. >         if (BN_abs_is_word(m, 1)) {
    183.               ret = 1;
    184.               BN_zero(r);

crypto/bn/bn_lib.c:900:1: start of procedure BN_abs_is_word()
      898.   }
      899.   
      900. > int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
      901.   {
      902.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));

crypto/bn/bn_lib.c:902:14: Condition is true
      900.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
      901.   {
      902.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
                          ^
      903.   }
      904.   

crypto/bn/bn_lib.c:902:31: Condition is false
      900.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
      901.   {
      902.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
                                           ^
      903.   }
      904.   

crypto/bn/bn_lib.c:902:51: Condition is false
      900.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
      901.   {
      902.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
                                                               ^
      903.   }
      904.   

crypto/bn/bn_lib.c:902:12: 
      900.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
      901.   {
      902. >     return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
      903.   }
      904.   

crypto/bn/bn_lib.c:902:5: 
      900.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
      901.   {
      902. >     return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
      903.   }
      904.   

crypto/bn/bn_lib.c:903:1: return from a call to BN_abs_is_word
      901.   {
      902.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
      903. > }
      904.   
      905.   int BN_is_zero(const BIGNUM *a)

crypto/bn/bn_exp.c:182:13: Taking false branch
    180.       if (bits == 0) {
    181.           /* x**0 mod 1, or x**0 mod -1 is still zero. */
    182.           if (BN_abs_is_word(m, 1)) {
                       ^
    183.               ret = 1;
    184.               BN_zero(r);

crypto/bn/bn_exp.c:186:13: Skipping BN_set_word(): empty list of specs
    184.               BN_zero(r);
    185.           } else {
    186.               ret = BN_one(r);
                       ^
    187.           }
    188.           return ret;

crypto/bn/bn_exp.c:188:9: 
    186.               ret = BN_one(r);
    187.           }
    188. >         return ret;
    189.       }
    190.   

crypto/bn/bn_exp.c:294:1: return from a call to BN_mod_exp_recp
    292.       bn_check_top(r);
    293.       return ret;
    294. > }
    295.   
    296.   int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,

crypto/bn/bn_exp.c:158:5: 
  156.   
  157.       bn_check_top(r);
  158. >     return ret;
  159.   }
  160.   

crypto/bn/bn_exp.c:159:1: return from a call to BN_mod_exp
  157.       bn_check_top(r);
  158.       return ret;
  159. > }
  160.   
  161.   int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
