test/rsa_sp800_56b_test.c:222: error: BUFFER_OVERRUN_L3
  Offset: [-1, +oo] Size: [1, +oo] by call to `rsa_check_prime_factor_range`.
Showing all 11 steps of the trace


test/rsa_sp800_56b_test.c:222:14: Call
220.             && TEST_ptr(ctx = BN_CTX_new())
221.             && TEST_true(BN_set_word(p, 0xA))
222.             && TEST_false(rsa_check_prime_factor_range(p, 8, ctx))
                    ^
223.             && TEST_true(BN_set_word(p, 0x10))
224.             && TEST_false(rsa_check_prime_factor_range(p, 8, ctx))

crypto/rsa/rsa_sp800_56b_check.c:95:5: Call
  93.           return 0;
  94.   
  95.       BN_CTX_start(ctx);
            ^
  96.       tmp = BN_CTX_get(ctx);
  97.       low = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:171:1: Parameter `*ctx->stack.indexes`
    169.   }
    170.   
    171. > void BN_CTX_start(BN_CTX *ctx)
    172.   {
    173.       CTXDBG("ENTER BN_CTX_start()", ctx);

crypto/rsa/rsa_sp800_56b_check.c:113:5: Call
  111.       ret = 1;
  112.   err:
  113.       BN_CTX_end(ctx);
             ^
  114.       return ret;
  115.   }

crypto/bn/bn_ctx.c:185:1: Parameter `*ctx->stack.indexes`
    183.   }
    184.   
    185. > void BN_CTX_end(BN_CTX *ctx)
    186.   {
    187.       CTXDBG("ENTER BN_CTX_end()", ctx);

crypto/bn/bn_ctx.c:191:27: Call
    189.           ctx->err_stack--;
    190.       else {
    191.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                     ^
    192.           /* Does this stack frame have anything to release? */
    193.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:266:1: <Offset trace>
264.   }
265.   
266. > static unsigned int BN_STACK_pop(BN_STACK *st)
267.   {
268.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:266:1: Parameter `st->depth`
      264.   }
      265.   
      266. > static unsigned int BN_STACK_pop(BN_STACK *st)
      267.   {
      268.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:266:1: <Length trace>
264.   }
265.   
266. > static unsigned int BN_STACK_pop(BN_STACK *st)
267.   {
268.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:266:1: Parameter `*st->indexes`
      264.   }
      265.   
      266. > static unsigned int BN_STACK_pop(BN_STACK *st)
      267.   {
      268.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:268:12: Array access: Offset: [-1, +oo] Size: [1, +oo] by call to `rsa_check_prime_factor_range` 
      266.   static unsigned int BN_STACK_pop(BN_STACK *st)
      267.   {
      268.       return st->indexes[--(st->depth)];
                        ^
      269.   }
      270.   

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['static int test_check_prime_factor_range(void)\n{\n    int ret = 0;\n    BN_CTX *ctx = NULL;\n    BIGNUM *p = NULL;\n    BIGNUM *bn_p1 = NULL, *bn_p2 = NULL, *bn_p3 = NULL, *bn_p4 = NULL;\n    static const unsigned char p1[] = { 0x0B, 0x50, 0x4F, 0x33, 0x3F };\n    static const unsigned char p2[] = { 0x10, 0x00, 0x00, 0x00, 0x00 };\n    static const unsigned char p3[] = { 0x0B, 0x50, 0x4F, 0x33, 0x40 };\n    static const unsigned char p4[] = { 0x0F, 0xFF, 0xFF, 0xFF, 0xFF };\n    ret = TEST_ptr(p = BN_new())\n          && TEST_ptr(bn_p1 = bn_load_new(p1, sizeof(p1)))\n          && TEST_ptr(bn_p2 = bn_load_new(p2, sizeof(p2)))\n          && TEST_ptr(bn_p3 = bn_load_new(p3, sizeof(p3)))\n          && TEST_ptr(bn_p4 = bn_load_new(p4, sizeof(p4)))\n          && TEST_ptr(ctx = BN_CTX_new())\n          && TEST_true(BN_set_word(p, 0xA))\n          && TEST_false(rsa_check_prime_factor_range(p, 8, ctx))\n          && TEST_true(BN_set_word(p, 0x10))\n          && TEST_false(rsa_check_prime_factor_range(p, 8, ctx))\n          && TEST_true(BN_set_word(p, 0xB))\n          && TEST_true(rsa_check_prime_factor_range(p, 8, ctx))\n          && TEST_true(BN_set_word(p, 0xF))\n          && TEST_true(rsa_check_prime_factor_range(p, 8, ctx))\n          && TEST_false(rsa_check_prime_factor_range(bn_p1, 72, ctx))\n          && TEST_false(rsa_check_prime_factor_range(bn_p2, 72, ctx))\n          && TEST_true(rsa_check_prime_factor_range(bn_p3, 72, ctx))\n          && TEST_true(rsa_check_prime_factor_range(bn_p4, 72, ctx));\n    BN_free(bn_p4);\n    BN_free(bn_p3);\n    BN_free(bn_p2);\n    BN_free(bn_p1);\n    BN_free(p);\n    BN_CTX_free(ctx);\n    return ret;\n}', 'int rsa_check_prime_factor_range(const BIGNUM *p, int nbits, BN_CTX *ctx)\n{\n    int ret = 0;\n    BIGNUM *tmp, *low;\n    nbits >>= 1;\n    if (BN_num_bits(p) != nbits)\n        return 0;\n    BN_CTX_start(ctx);\n    tmp = BN_CTX_get(ctx);\n    low = BN_CTX_get(ctx);\n    if (low == NULL || !BN_set_word(tmp, 0xB504F334))\n        goto err;\n    if (nbits >= 32) {\n        if (!BN_lshift(low, tmp, nbits - 32))\n            goto err;\n    } else if (!BN_rshift(low, tmp, 32 - nbits)) {\n        goto err;\n    }\n    if (BN_cmp(p, low) < 0)\n        goto err;\n    ret = 1;\nerr:\n    BN_CTX_end(ctx);\n    return ret;\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG("ENTER 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("LEAVE BN_CTX_start()", ctx);\n}', 'void BN_CTX_end(BN_CTX *ctx)\n{\n    CTXDBG("ENTER BN_CTX_end()", ctx);\n    if (ctx->err_stack)\n        ctx->err_stack--;\n    else {\n        unsigned int fp = BN_STACK_pop(&ctx->stack);\n        if (fp < ctx->used)\n            BN_POOL_release(&ctx->pool, ctx->used - fp);\n        ctx->used = fp;\n        ctx->too_many = 0;\n    }\n    CTXDBG("LEAVE BN_CTX_end()", ctx);\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']