ssl/statem/extensions_clnt.c:538: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - [`pkt->written`, `pkt->written` + 2]):unsigned64 by call to `WPACKET_put_bytes__`.
Showing all 12 steps of the trace


ssl/statem/extensions_clnt.c:537:10: Call
535.           return EXT_RETURN_NOT_SENT;
536.   
537.       if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_extended_master_secret)
                ^
538.               || !WPACKET_put_bytes_u16(pkt, 0)) {
539.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CTOS_EMS,

crypto/packet.c:329:1: Parameter `pkt->buf->length`
  327.   }
  328.   
  329. > int WPACKET_put_bytes__(WPACKET *pkt, unsigned int val, size_t size)
  330.   {
  331.       unsigned char *data;

ssl/statem/extensions_clnt.c:538:17: Call
536.   
537.       if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_extended_master_secret)
538.               || !WPACKET_put_bytes_u16(pkt, 0)) {
                       ^
539.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CTOS_EMS,
540.                    ERR_R_INTERNAL_ERROR);

crypto/packet.c:329:1: Parameter `pkt->written`
  327.   }
  328.   
  329. > int WPACKET_put_bytes__(WPACKET *pkt, unsigned int val, size_t size)
  330.   {
  331.       unsigned char *data;

crypto/packet.c:335:17: Call
  333.       /* Internal API, so should not fail */
  334.       if (!ossl_assert(size <= sizeof(unsigned int))
  335.               || !WPACKET_allocate_bytes(pkt, size, &data)
                         ^
  336.               || !put_value(data, val, size))
  337.           return 0;

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:43:1: <LHS trace>
41.                           : NULL))
42.   
43. > int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
44.   {
45.       /* Internal API, so should not fail */

crypto/packet.c:43:1: Parameter `pkt->buf->length`
      41.                           : NULL))
      42.   
      43. > int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
      44.   {
      45.       /* Internal API, so should not fail */

crypto/packet.c:43:1: <RHS trace>
41.                           : NULL))
42.   
43. > int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
44.   {
45.       /* Internal API, so should not fail */

crypto/packet.c:43:1: Parameter `len`
      41.                           : NULL))
      42.   
      43. > int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
      44.   {
      45.       /* Internal API, so should not fail */

crypto/packet.c:52:30: Binary operation: ([0, +oo] - [pkt->written, pkt->written + 2]):unsigned64 by call to `WPACKET_put_bytes__` 
      50.           return 0;
      51.   
      52.       if (pkt->buf != NULL && (pkt->buf->length - pkt->written < len)) {
                                         ^
      53.           size_t newlen;
      54.           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->buf != 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;
}
['EXT_RETURN tls_construct_ctos_ems(SSL *s, WPACKET *pkt, unsigned int context,\n                                  X509 *x, size_t chainidx)\n{\n    if (s->options & SSL_OP_NO_EXTENDED_MASTER_SECRET)\n        return EXT_RETURN_NOT_SENT;\n    if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_extended_master_secret)\n            || !WPACKET_put_bytes_u16(pkt, 0)) {\n        SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CTOS_EMS,\n                 ERR_R_INTERNAL_ERROR);\n        return EXT_RETURN_FAIL;\n    }\n    return EXT_RETURN_SENT;\n}', 'int WPACKET_put_bytes__(WPACKET *pkt, unsigned int val, size_t size)\n{\n    unsigned char *data;\n    if (!ossl_assert(size <= sizeof(unsigned int))\n            || !WPACKET_allocate_bytes(pkt, size, &data)\n            || !put_value(data, val, size))\n        return 0;\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->buf != 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}']