test/servername_test.c:51: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 5):unsigned64 by call to `PACKET_forward`.
Showing all 10 steps of the trace


test/servername_test.c:49:10: Call
47.   
48.       len = BIO_get_mem_data(bio, (char **)&data);
49.       if (!TEST_true(PACKET_buf_init(&pkt, data, len))
               ^
50.                  /* Skip the record header */
51.               || !PACKET_forward(&pkt, SSL3_RT_HEADER_LENGTH)

ssl/packet_locl.h:68:8: Parameter `pkt->remaining`
  66.    * is being used.
  67.    */
  68.   __owur static ossl_inline int PACKET_buf_init(PACKET *pkt,
               ^
  69.                                                 const unsigned char *buf,
  70.                                                 size_t len)

test/servername_test.c:51:17: Call
49.       if (!TEST_true(PACKET_buf_init(&pkt, data, len))
50.                  /* Skip the record header */
51.               || !PACKET_forward(&pkt, SSL3_RT_HEADER_LENGTH)
                      ^
52.                  /* Skip the handshake message header */
53.               || !TEST_true(PACKET_forward(&pkt, SSL3_HM_HEADER_LENGTH))

ssl/packet_locl.h:463:8: Parameter `len`
  461.   
  462.   /* Move the current reading position forward |len| bytes */
  463.   __owur static ossl_inline int PACKET_forward(PACKET *pkt, size_t len)
                ^
  464.   {
  465.       if (PACKET_remaining(pkt) < len)

ssl/packet_locl.h:468:5: Call
  466.           return 0;
  467.   
  468.       packet_forward(pkt, len);
             ^
  469.   
  470.       return 1;

ssl/packet_locl.h:29:1: <LHS trace>
27.   
28.   /* Internal unchecked shorthand; don't use outside this file. */
29. > static ossl_inline void packet_forward(PACKET *pkt, size_t len)
30.   {
31.       pkt->curr += len;

ssl/packet_locl.h:29:1: Parameter `pkt->remaining`
    27.   
    28.   /* Internal unchecked shorthand; don't use outside this file. */
    29. > static ossl_inline void packet_forward(PACKET *pkt, size_t len)
    30.   {
    31.       pkt->curr += len;

ssl/packet_locl.h:29:1: <RHS trace>
27.   
28.   /* Internal unchecked shorthand; don't use outside this file. */
29. > static ossl_inline void packet_forward(PACKET *pkt, size_t len)
30.   {
31.       pkt->curr += len;

ssl/packet_locl.h:29:1: Parameter `len`
    27.   
    28.   /* Internal unchecked shorthand; don't use outside this file. */
    29. > static ossl_inline void packet_forward(PACKET *pkt, size_t len)
    30.   {
    31.       pkt->curr += len;

ssl/packet_locl.h:32:5: Binary operation: ([0, +oo] - 5):unsigned64 by call to `PACKET_forward` 
    30.   {
    31.       pkt->curr += len;
    32.       pkt->remaining -= len;
              ^
    33.   }
    34.   

static ossl_inline void packet_forward(PACKET *pkt, size_t len)
{
    pkt->curr += len;
    pkt->remaining -= len;
}
['static int get_sni_from_client_hello(BIO *bio, char **sni)\n{\n    long len;\n    unsigned char *data;\n    PACKET pkt, pkt2, pkt3, pkt4, pkt5;\n    unsigned int servname_type = 0, type = 0;\n    int ret = 0;\n    memset(&pkt, 0, sizeof(pkt));\n    memset(&pkt2, 0, sizeof(pkt2));\n    memset(&pkt3, 0, sizeof(pkt3));\n    memset(&pkt4, 0, sizeof(pkt4));\n    memset(&pkt5, 0, sizeof(pkt5));\n    len = BIO_get_mem_data(bio, (char **)&data);\n    if (!TEST_true(PACKET_buf_init(&pkt, data, len))\n            || !PACKET_forward(&pkt, SSL3_RT_HEADER_LENGTH)\n            || !TEST_true(PACKET_forward(&pkt, SSL3_HM_HEADER_LENGTH))\n            || !TEST_true(PACKET_forward(&pkt, CLIENT_VERSION_LEN\n                                               + SSL3_RANDOM_SIZE))\n            || !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))\n            || !TEST_true(PACKET_get_length_prefixed_2(&pkt, &pkt2))\n            || !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))\n            || !TEST_true(PACKET_as_length_prefixed_2(&pkt, &pkt2)))\n        goto end;\n    while (PACKET_remaining(&pkt2)) {\n        if (!TEST_true(PACKET_get_net_2(&pkt2, &type))\n                || !TEST_true(PACKET_get_length_prefixed_2(&pkt2, &pkt3)))\n            goto end;\n        if (type == TLSEXT_TYPE_server_name) {\n            if (!TEST_true(PACKET_get_length_prefixed_2(&pkt3, &pkt4))\n                    || !TEST_uint_ne(PACKET_remaining(&pkt4), 0)\n                    || !TEST_true(PACKET_get_1(&pkt4, &servname_type))\n                    || !TEST_uint_eq(servname_type, TLSEXT_NAMETYPE_host_name)\n                    || !TEST_true(PACKET_get_length_prefixed_2(&pkt4, &pkt5))\n                    || !TEST_uint_le(PACKET_remaining(&pkt5), TLSEXT_MAXLEN_host_name)\n                    || !TEST_false(PACKET_contains_zero_byte(&pkt5))\n                    || !TEST_true(PACKET_strndup(&pkt5, sni)))\n                goto end;\n            ret = 1;\n            goto end;\n        }\n    }\nend:\n    return ret;\n}', 'static ossl_inline int PACKET_buf_init(PACKET *pkt,\n                                              const unsigned char *buf,\n                                              size_t len)\n{\n    if (len > (size_t)(SIZE_MAX / 2))\n        return 0;\n    pkt->curr = buf;\n    pkt->remaining = len;\n    return 1;\n}', 'static ossl_inline int PACKET_forward(PACKET *pkt, size_t len)\n{\n    if (PACKET_remaining(pkt) < len)\n        return 0;\n    packet_forward(pkt, len);\n    return 1;\n}', 'static ossl_inline void packet_forward(PACKET *pkt, size_t len)\n{\n    pkt->curr += len;\n    pkt->remaining -= len;\n}']