ssl/statem/statem_clnt.c:3339: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - [0, `pkt->written` + 130]):unsigned64 by call to `tls_construct_cke_srp`.
Showing all 15 steps of the trace


ssl/statem/statem_clnt.c:3312:1: Parameter `pkt->written`
3310.   }
3311.   
3312. > int tls_construct_client_key_exchange(SSL *s, WPACKET *pkt)
3313.   {
3314.       unsigned long alg_k;

ssl/statem/statem_clnt.c:3339:14: Call
3337.               goto err;
3338.       } else if (alg_k & SSL_kSRP) {
3339.           if (!tls_construct_cke_srp(s, pkt))
                     ^
3340.               goto err;
3341.       } else if (!(alg_k & SSL_kPSK)) {

ssl/statem/statem_clnt.c:3282:1: Parameter `pkt->written`
  3280.   }
  3281.   
  3282. > static int tls_construct_cke_srp(SSL *s, WPACKET *pkt)
  3283.   {
  3284.   #ifndef OPENSSL_NO_SRP

ssl/statem/statem_clnt.c:3288:17: Call
  3286.   
  3287.       if (s->srp_ctx.A == NULL
  3288.               || !WPACKET_sub_allocate_bytes_u16(pkt, BN_num_bytes(s->srp_ctx.A),
                          ^
  3289.                                                  &abytes)) {
  3290.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_SRP,

crypto/packet.c:26:1: Parameter `pkt->written`
    24.   }
    25.   
    26. > int WPACKET_sub_allocate_bytes__(WPACKET *pkt, size_t len,
    27.                                    unsigned char **allocbytes, size_t lenbytes)
    28.   {

crypto/packet.c:29:10: Call
    27.                                    unsigned char **allocbytes, size_t lenbytes)
    28.   {
    29.       if (!WPACKET_start_sub_packet_len__(pkt, lenbytes)
                   ^
    30.               || !WPACKET_allocate_bytes(pkt, len, allocbytes)
    31.               || !WPACKET_close(pkt))

crypto/packet.c:272:1: Parameter `pkt->written`
      270.   }
      271.   
      272. > int WPACKET_start_sub_packet_len__(WPACKET *pkt, size_t lenbytes)
      273.   {
      274.       WPACKET_SUB *sub;

crypto/packet.c:296:10: Call
      294.       }
      295.   
      296.       if (!WPACKET_allocate_bytes(pkt, lenbytes, &lenchars))
                      ^
      297.           return 0;
      298.       /* Convert to an offset in case the underlying BUF_MEM gets realloc'd */

crypto/packet.c:16:1: Parameter `pkt->written`
        14.   #define DEFAULT_BUF_SIZE    256
        15.   
        16. > int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
        17.   {
        18.       if (!WPACKET_reserve_bytes(pkt, len, allocbytes))

crypto/packet.c:18:10: Call
        16.   int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
        17.   {
        18.       if (!WPACKET_reserve_bytes(pkt, len, allocbytes))
                       ^
        19.           return 0;
        20.   

crypto/packet.c:40:1: <LHS trace>
38.                        ? (p)->staticbuf : (unsigned char *)(p)->buf->data)
39.   
40. > int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
41.   {
42.       /* Internal API, so should not fail */

crypto/packet.c:40:1: Parameter `pkt->buf->length`
          38.                        ? (p)->staticbuf : (unsigned char *)(p)->buf->data)
          39.   
          40. > int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
          41.   {
          42.       /* Internal API, so should not fail */

crypto/packet.c:40:1: <RHS trace>
38.                        ? (p)->staticbuf : (unsigned char *)(p)->buf->data)
39.   
40. > int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
41.   {
42.       /* Internal API, so should not fail */

crypto/packet.c:40:1: Parameter `len`
          38.                        ? (p)->staticbuf : (unsigned char *)(p)->buf->data)
          39.   
          40. > int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
          41.   {
          42.       /* Internal API, so should not fail */

crypto/packet.c:49:36: Binary operation: ([0, +oo] - [0, pkt->written + 130]):unsigned64 by call to `tls_construct_cke_srp` 
          47.           return 0;
          48.   
          49.       if (pkt->staticbuf == NULL && (pkt->buf->length - pkt->written < len)) {
                                                   ^
          50.           size_t newlen;
          51.           size_t reflen;

int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
{
    if (!ossl_assert(pkt->subs != NULL && len != 0))
        return 0;
    if (pkt->maxsize - pkt->written < len)
        return 0;
    if (pkt->staticbuf == NULL && (pkt->buf->length - pkt->written < len)) {
        size_t newlen;
        size_t reflen;
        reflen = (len > pkt->buf->length) ? len : pkt->buf->length;
        if (reflen > SIZE_MAX / 2) {
            newlen = SIZE_MAX;
        } else {
            newlen = reflen * 2;
            if (newlen < DEFAULT_BUF_SIZE)
                newlen = DEFAULT_BUF_SIZE;
        }
        if (BUF_MEM_grow(pkt->buf, newlen) == 0)
            return 0;
    }
    if (allocbytes != NULL)
        *allocbytes = WPACKET_get_curr(pkt);
    return 1;
}
['int tls_construct_client_key_exchange(SSL *s, WPACKET *pkt)\n{\n    unsigned long alg_k;\n    alg_k = s->s3.tmp.new_cipher->algorithm_mkey;\n    if ((alg_k & SSL_PSK)\n        && !tls_construct_cke_psk_preamble(s, pkt))\n        goto err;\n    if (alg_k & (SSL_kRSA | SSL_kRSAPSK)) {\n        if (!tls_construct_cke_rsa(s, pkt))\n            goto err;\n    } else if (alg_k & (SSL_kDHE | SSL_kDHEPSK)) {\n        if (!tls_construct_cke_dhe(s, pkt))\n            goto err;\n    } else if (alg_k & (SSL_kECDHE | SSL_kECDHEPSK)) {\n        if (!tls_construct_cke_ecdhe(s, pkt))\n            goto err;\n    } else if (alg_k & SSL_kGOST) {\n        if (!tls_construct_cke_gost(s, pkt))\n            goto err;\n    } else if (alg_k & SSL_kSRP) {\n        if (!tls_construct_cke_srp(s, pkt))\n            goto err;\n    } else if (!(alg_k & SSL_kPSK)) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR,\n                 SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);\n        goto err;\n    }\n    return 1;\n err:\n    OPENSSL_clear_free(s->s3.tmp.pms, s->s3.tmp.pmslen);\n    s->s3.tmp.pms = NULL;\n#ifndef OPENSSL_NO_PSK\n    OPENSSL_clear_free(s->s3.tmp.psk, s->s3.tmp.psklen);\n    s->s3.tmp.psk = NULL;\n#endif\n    return 0;\n}', 'static int tls_construct_cke_srp(SSL *s, WPACKET *pkt)\n{\n#ifndef OPENSSL_NO_SRP\n    unsigned char *abytes = NULL;\n    if (s->srp_ctx.A == NULL\n            || !WPACKET_sub_allocate_bytes_u16(pkt, BN_num_bytes(s->srp_ctx.A),\n                                               &abytes)) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_SRP,\n                 ERR_R_INTERNAL_ERROR);\n        return 0;\n    }\n    BN_bn2bin(s->srp_ctx.A, abytes);\n    OPENSSL_free(s->session->srp_username);\n    s->session->srp_username = OPENSSL_strdup(s->srp_ctx.login);\n    if (s->session->srp_username == NULL) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_SRP,\n                 ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    return 1;\n#else\n    SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_SRP,\n             ERR_R_INTERNAL_ERROR);\n    return 0;\n#endif\n}', 'int WPACKET_sub_allocate_bytes__(WPACKET *pkt, size_t len,\n                                 unsigned char **allocbytes, size_t lenbytes)\n{\n    if (!WPACKET_start_sub_packet_len__(pkt, lenbytes)\n            || !WPACKET_allocate_bytes(pkt, len, allocbytes)\n            || !WPACKET_close(pkt))\n        return 0;\n    return 1;\n}', 'int WPACKET_start_sub_packet_len__(WPACKET *pkt, size_t lenbytes)\n{\n    WPACKET_SUB *sub;\n    unsigned char *lenchars;\n    if (!ossl_assert(pkt->subs != NULL))\n        return 0;\n    if ((sub = OPENSSL_zalloc(sizeof(*sub))) == NULL) {\n        SSLerr(SSL_F_WPACKET_START_SUB_PACKET_LEN__, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    sub->parent = pkt->subs;\n    pkt->subs = sub;\n    sub->pwritten = pkt->written + lenbytes;\n    sub->lenbytes = lenbytes;\n    if (lenbytes == 0) {\n        sub->packet_len = 0;\n        return 1;\n    }\n    if (!WPACKET_allocate_bytes(pkt, lenbytes, &lenchars))\n        return 0;\n    sub->packet_len = lenchars - GETBUF(pkt);\n    return 1;\n}', 'int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)\n{\n    if (!WPACKET_reserve_bytes(pkt, len, allocbytes))\n        return 0;\n    pkt->written += len;\n    pkt->curr += len;\n    return 1;\n}', 'int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)\n{\n    if (!ossl_assert(pkt->subs != NULL && len != 0))\n        return 0;\n    if (pkt->maxsize - pkt->written < len)\n        return 0;\n    if (pkt->staticbuf == NULL && (pkt->buf->length - pkt->written < len)) {\n        size_t newlen;\n        size_t reflen;\n        reflen = (len > pkt->buf->length) ? len : pkt->buf->length;\n        if (reflen > SIZE_MAX / 2) {\n            newlen = SIZE_MAX;\n        } else {\n            newlen = reflen * 2;\n            if (newlen < DEFAULT_BUF_SIZE)\n                newlen = DEFAULT_BUF_SIZE;\n        }\n        if (BUF_MEM_grow(pkt->buf, newlen) == 0)\n            return 0;\n    }\n    if (allocbytes != NULL)\n        *allocbytes = WPACKET_get_curr(pkt);\n    return 1;\n}']