crypto/bn/bn_x931p.c:227: error: NULL_DEREFERENCE
  pointer `t` last assigned on line 220 could be null and is dereferenced by call to `BN_num_bits()` at line 227, column 13.
Showing all 32 steps of the trace


crypto/bn/bn_x931p.c:200:1: start of procedure BN_X931_generate_Xpq()
198.    */
199.   
200. > int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
201.   {
202.       BIGNUM *t;

crypto/bn/bn_x931p.c:208:10: Taking false branch
206.        * ...
207.        */
208.       if ((nbits < 1024) || (nbits & 0xff))
                ^
209.           return 0;
210.       nbits >>= 1;

crypto/bn/bn_x931p.c:208:28: Taking false branch
206.        * ...
207.        */
208.       if ((nbits < 1024) || (nbits & 0xff))
                                  ^
209.           return 0;
210.       nbits >>= 1;

crypto/bn/bn_x931p.c:210:5: 
208.       if ((nbits < 1024) || (nbits & 0xff))
209.           return 0;
210. >     nbits >>= 1;
211.       /*
212.        * The random value Xp must be between sqrt(2) * 2^(nbits-1) and 2^nbits

crypto/bn/bn_x931p.c:216:10: 
214.        * exceeded.
215.        */
216. >     if (!BN_rand(Xp, nbits, 1, 0))
217.           return 0;
218.   

crypto/bn/bn_rand.c:200:1: start of procedure BN_rand()
  198.   }
  199.   
  200. > int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
  201.   {
  202.       return bnrand(0, rnd, bits, top, bottom);

crypto/bn/bn_rand.c:202:5: Skipping bnrand(): empty list of specs
  200.   int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
  201.   {
  202.       return bnrand(0, rnd, bits, top, bottom);
             ^
  203.   }
  204.   

crypto/bn/bn_rand.c:203:1: return from a call to BN_rand
  201.   {
  202.       return bnrand(0, rnd, bits, top, bottom);
  203. > }
  204.   
  205.   int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)

crypto/bn/bn_x931p.c:216:10: Taking false branch
214.        * exceeded.
215.        */
216.       if (!BN_rand(Xp, nbits, 1, 0))
                ^
217.           return 0;
218.   

crypto/bn/bn_x931p.c:219:5: 
217.           return 0;
218.   
219. >     BN_CTX_start(ctx);
220.       t = BN_CTX_get(ctx);
221.   

crypto/bn/bn_ctx.c:240:1: start of procedure BN_CTX_start()
  238.   }
  239.   
  240. > void BN_CTX_start(BN_CTX *ctx)
  241.   {
  242.       CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_ctx.c:244:9: Taking false branch
  242.       CTXDBG_ENTRY("BN_CTX_start", ctx);
  243.       /* If we're already overflowing ... */
  244.       if (ctx->err_stack || ctx->too_many)
                 ^
  245.           ctx->err_stack++;
  246.       /* (Try to) get a new frame pointer */

crypto/bn/bn_ctx.c:244:27: Taking true branch
  242.       CTXDBG_ENTRY("BN_CTX_start", ctx);
  243.       /* If we're already overflowing ... */
  244.       if (ctx->err_stack || ctx->too_many)
                                   ^
  245.           ctx->err_stack++;
  246.       /* (Try to) get a new frame pointer */

crypto/bn/bn_ctx.c:245:9: 
  243.       /* If we're already overflowing ... */
  244.       if (ctx->err_stack || ctx->too_many)
  245. >         ctx->err_stack++;
  246.       /* (Try to) get a new frame pointer */
  247.       else if (!BN_STACK_push(&ctx->stack, ctx->used)) {

crypto/bn/bn_ctx.c:244:5: 
  242.       CTXDBG_ENTRY("BN_CTX_start", ctx);
  243.       /* If we're already overflowing ... */
  244. >     if (ctx->err_stack || ctx->too_many)
  245.           ctx->err_stack++;
  246.       /* (Try to) get a new frame pointer */

crypto/bn/bn_ctx.c:252:1: return from a call to BN_CTX_start
  250.       }
  251.       CTXDBG_EXIT(ctx);
  252. > }
  253.   
  254.   void BN_CTX_end(BN_CTX *ctx)

crypto/bn/bn_x931p.c:220:5: 
218.   
219.       BN_CTX_start(ctx);
220. >     t = BN_CTX_get(ctx);
221.   
222.       for (i = 0; i < 1000; i++) {

crypto/bn/bn_ctx.c:271:1: start of procedure BN_CTX_get()
  269.   }
  270.   
  271. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
  272.   {
  273.       BIGNUM *ret;

crypto/bn/bn_ctx.c:276:9: Taking true branch
  274.   
  275.       CTXDBG_ENTRY("BN_CTX_get", ctx);
  276.       if (ctx->err_stack || ctx->too_many)
                 ^
  277.           return NULL;
  278.       if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {

crypto/bn/bn_ctx.c:277:9: 
  275.       CTXDBG_ENTRY("BN_CTX_get", ctx);
  276.       if (ctx->err_stack || ctx->too_many)
  277. >         return NULL;
  278.       if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {
  279.           /*

crypto/bn/bn_ctx.c:292:1: return from a call to BN_CTX_get
  290.       CTXDBG_RET(ctx, ret);
  291.       return ret;
  292. > }
  293.   
  294.   /************/

crypto/bn/bn_x931p.c:222:10: 
220.       t = BN_CTX_get(ctx);
221.   
222. >     for (i = 0; i < 1000; i++) {
223.           if (!BN_rand(Xq, nbits, 1, 0))
224.               return 0;

crypto/bn/bn_x931p.c:222:17: Loop condition is true. Entering loop body
220.       t = BN_CTX_get(ctx);
221.   
222.       for (i = 0; i < 1000; i++) {
                       ^
223.           if (!BN_rand(Xq, nbits, 1, 0))
224.               return 0;

crypto/bn/bn_x931p.c:223:14: 
221.   
222.       for (i = 0; i < 1000; i++) {
223. >         if (!BN_rand(Xq, nbits, 1, 0))
224.               return 0;
225.           /* Check that |Xp - Xq| > 2^(nbits - 100) */

crypto/bn/bn_rand.c:200:1: start of procedure BN_rand()
  198.   }
  199.   
  200. > int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
  201.   {
  202.       return bnrand(0, rnd, bits, top, bottom);

crypto/bn/bn_rand.c:202:5: Skipping bnrand(): empty list of specs
  200.   int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
  201.   {
  202.       return bnrand(0, rnd, bits, top, bottom);
             ^
  203.   }
  204.   

crypto/bn/bn_rand.c:203:1: return from a call to BN_rand
  201.   {
  202.       return bnrand(0, rnd, bits, top, bottom);
  203. > }
  204.   
  205.   int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)

crypto/bn/bn_x931p.c:223:14: Taking false branch
221.   
222.       for (i = 0; i < 1000; i++) {
223.           if (!BN_rand(Xq, nbits, 1, 0))
                    ^
224.               return 0;
225.           /* Check that |Xp - Xq| > 2^(nbits - 100) */

crypto/bn/bn_x931p.c:226:9: Skipping BN_sub(): empty list of specs
224.               return 0;
225.           /* Check that |Xp - Xq| > 2^(nbits - 100) */
226.           BN_sub(t, Xp, Xq);
               ^
227.           if (BN_num_bits(t) > (nbits - 100))
228.               break;

crypto/bn/bn_x931p.c:227:13: 
225.           /* Check that |Xp - Xq| > 2^(nbits - 100) */
226.           BN_sub(t, Xp, Xq);
227. >         if (BN_num_bits(t) > (nbits - 100))
228.               break;
229.       }

crypto/bn/bn_lib.c:214:1: start of procedure BN_num_bits()
  212.   }
  213.   
  214. > int BN_num_bits(const BIGNUM *a)
  215.   {
  216.       int i = a->top - 1;

crypto/bn/bn_lib.c:216:5: 
  214.   int BN_num_bits(const BIGNUM *a)
  215.   {
  216. >     int i = a->top - 1;
  217.       bn_check_top(a);
  218.   

int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
{
    BIGNUM *t;
    int i;
    if ((nbits < 1024) || (nbits & 0xff))
        return 0;
    nbits >>= 1;
    if (!BN_rand(Xp, nbits, 1, 0))
        return 0;
    BN_CTX_start(ctx);
    t = BN_CTX_get(ctx);
    for (i = 0; i < 1000; i++) {
        if (!BN_rand(Xq, nbits, 1, 0))
            return 0;
        BN_sub(t, Xp, Xq);
        if (BN_num_bits(t) > (nbits - 100))
            break;
    }
    BN_CTX_end(ctx);
    if (i < 1000)
        return 1;
    return 0;
}
['int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)\n{\n    BIGNUM *t;\n    int i;\n    if ((nbits < 1024) || (nbits & 0xff))\n        return 0;\n    nbits >>= 1;\n    if (!BN_rand(Xp, nbits, 1, 0))\n        return 0;\n    BN_CTX_start(ctx);\n    t = BN_CTX_get(ctx);\n    for (i = 0; i < 1000; i++) {\n        if (!BN_rand(Xq, nbits, 1, 0))\n            return 0;\n        BN_sub(t, Xp, Xq);\n        if (BN_num_bits(t) > (nbits - 100))\n            break;\n    }\n    BN_CTX_end(ctx);\n    if (i < 1000)\n        return 1;\n    return 0;\n}', 'int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)\n{\n    return bnrand(0, rnd, bits, top, bottom);\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG_ENTRY("BN_CTX_start", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        ctx->err_stack++;\n    else if (!BN_STACK_push(&ctx->stack, ctx->used)) {\n        BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        ctx->err_stack++;\n    }\n    CTXDBG_EXIT(ctx);\n}', 'BIGNUM *BN_CTX_get(BN_CTX *ctx)\n{\n    BIGNUM *ret;\n    CTXDBG_ENTRY("BN_CTX_get", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        return NULL;\n    if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {\n        ctx->too_many = 1;\n        BNerr(BN_F_BN_CTX_GET, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        return NULL;\n    }\n    BN_zero(ret);\n    ctx->used++;\n    CTXDBG_RET(ctx, ret);\n    return ret;\n}', 'int BN_num_bits(const BIGNUM *a)\n{\n    int i = a->top - 1;\n    bn_check_top(a);\n    if (BN_is_zero(a))\n        return 0;\n    return ((i * BN_BITS2) + BN_num_bits_word(a->d[i]));\n}']