crypto/srp/srp_vfy.c:569: error: BUFFER_OVERRUN_L3
  Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_bin2bn`.
Showing all 14 steps of the trace


crypto/srp/srp_vfy.c:568:32: Call
566.       ctxt = NULL;
567.       if (SRP_user_pwd_set_sv_BN(user,
568.                                  BN_bin2bn(digs, SHA_DIGEST_LENGTH, NULL),
                                      ^
569.                                  BN_bin2bn(digv, SHA_DIGEST_LENGTH, NULL)))
570.           return user;

crypto/bn/bn_lib.c:371:1: Parameter `*ret->d`
  369.   }
  370.   
  371. > BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
  372.   {
  373.       unsigned int i, m;

crypto/srp/srp_vfy.c:569:32: Call
567.       if (SRP_user_pwd_set_sv_BN(user,
568.                                  BN_bin2bn(digs, SHA_DIGEST_LENGTH, NULL),
569.                                  BN_bin2bn(digv, SHA_DIGEST_LENGTH, NULL)))
                                      ^
570.           return user;
571.   

crypto/bn/bn_lib.c:371:1: Parameter `*ret->d`
  369.   }
  370.   
  371. > BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
  372.   {
  373.       unsigned int i, m;

crypto/bn/bn_lib.c:393:9: Call
  391.       i = ((n - 1) / BN_BYTES) + 1;
  392.       m = ((n - 1) % (BN_BYTES));
  393.       if (bn_wexpand(ret, (int)i) == NULL) {
                 ^
  394.           BN_free(bn);
  395.           return NULL;

crypto/bn/bn_lib.c:942:1: Parameter `*a->d`
    940.   }
    941.   
    942. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
    943.   {
    944.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_lib.c:944:37: Call
    942.   BIGNUM *bn_wexpand(BIGNUM *a, int words)
    943.   {
    944.       return (words <= a->dmax) ? a : bn_expand2(a, words);
                                               ^
    945.   }
    946.   

crypto/bn/bn_lib.c:244:1: Parameter `*b->d`
      242.    */
      243.   
      244. > BIGNUM *bn_expand2(BIGNUM *b, int words)
      245.   {
      246.       if (words > b->dmax) {

crypto/bn/bn_lib.c:247:23: Call
      245.   {
      246.       if (words > b->dmax) {
      247.           BN_ULONG *a = bn_expand_internal(b, words);
                                   ^
      248.           if (!a)
      249.               return NULL;

crypto/bn/bn_lib.c:208:1: <Offset trace>
206.   /* This is used by bn_expand2() */
207.   /* The caller MUST check that words > b->dmax before calling this */
208. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
209.   {
210.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:208:1: Parameter `b->top`
        206.   /* This is used by bn_expand2() */
        207.   /* The caller MUST check that words > b->dmax before calling this */
        208. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
        209.   {
        210.       BN_ULONG *a = NULL;

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

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

crypto/bn/bn_lib.c:231:9: Array access: Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_bin2bn` 
        229.       assert(b->top <= words);
        230.       if (b->top > 0)
        231.           memcpy(a, b->d, sizeof(*a) * b->top);
                       ^
        232.   
        233.       return a;

static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
{
    BN_ULONG *a = NULL;
    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 = OPENSSL_secure_zalloc(words * sizeof(*a));
    else
        a = OPENSSL_zalloc(words * sizeof(*a));
    if (a == NULL) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);
        return NULL;
    }
    assert(b->top <= words);
    if (b->top > 0)
        memcpy(a, b->d, sizeof(*a) * b->top);
    return a;
}
['SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username)\n{\n    SRP_user_pwd *user;\n    unsigned char digv[SHA_DIGEST_LENGTH];\n    unsigned char digs[SHA_DIGEST_LENGTH];\n    EVP_MD_CTX *ctxt = NULL;\n    if (vb == NULL)\n        return NULL;\n    if ((user = find_user(vb, username)) != NULL)\n        return srp_user_pwd_dup(user);\n    if ((vb->seed_key == NULL) ||\n        (vb->default_g == NULL) || (vb->default_N == NULL))\n        return NULL;\n    if ((user = SRP_user_pwd_new()) == NULL)\n        return NULL;\n    SRP_user_pwd_set_gN(user, vb->default_g, vb->default_N);\n    if (!SRP_user_pwd_set_ids(user, username, NULL))\n        goto err;\n    if (RAND_priv_bytes(digv, SHA_DIGEST_LENGTH) <= 0)\n        goto err;\n    ctxt = EVP_MD_CTX_new();\n    if (ctxt == NULL\n        || !EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL)\n        || !EVP_DigestUpdate(ctxt, vb->seed_key, strlen(vb->seed_key))\n        || !EVP_DigestUpdate(ctxt, username, strlen(username))\n        || !EVP_DigestFinal_ex(ctxt, digs, NULL))\n        goto err;\n    EVP_MD_CTX_free(ctxt);\n    ctxt = NULL;\n    if (SRP_user_pwd_set_sv_BN(user,\n                               BN_bin2bn(digs, SHA_DIGEST_LENGTH, NULL),\n                               BN_bin2bn(digv, SHA_DIGEST_LENGTH, NULL)))\n        return user;\n err:\n    EVP_MD_CTX_free(ctxt);\n    SRP_user_pwd_free(user);\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    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    return b;\n}', 'static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)\n{\n    BN_ULONG *a = NULL;\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 = OPENSSL_secure_zalloc(words * sizeof(*a));\n    else\n        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    assert(b->top <= words);\n    if (b->top > 0)\n        memcpy(a, b->d, sizeof(*a) * b->top);\n    return a;\n}']