test/packettest.c:182: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 4):unsigned64 by call to `PACKET_get_sub_packet`.
Showing all 10 steps of the trace


test/packettest.c:181:17: Call
179.       unsigned long i;
180.   
181.       if (       !PACKET_buf_init(&pkt, buf, BUF_LEN)
                       ^
182.               || !PACKET_get_sub_packet(&pkt, &subpkt, 4)
183.               || !PACKET_get_net_4(&subpkt, &i)

ssl/packet_locl.h:110:8: Parameter `pkt->remaining`
  108.    * is being used.
  109.    */
  110.   __owur static inline int PACKET_buf_init(PACKET *pkt, unsigned char *buf,
                ^
  111.                                            size_t len)
  112.   {

test/packettest.c:182:17: Call
180.   
181.       if (       !PACKET_buf_init(&pkt, buf, BUF_LEN)
182.               || !PACKET_get_sub_packet(&pkt, &subpkt, 4)
                       ^
183.               || !PACKET_get_net_4(&subpkt, &i)
184.               ||  i != 0x02040608UL

ssl/packet_locl.h:160:8: Parameter `len`
  158.    * original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|.
  159.    */
  160.   __owur static inline int PACKET_get_sub_packet(PACKET *pkt, PACKET *subpkt,
                ^
  161.                                                  size_t len)
  162.   {

ssl/packet_locl.h:166:5: Call
  164.           return 0;
  165.   
  166.       packet_forward(pkt, len);
             ^
  167.   
  168.       return 1;

ssl/packet_locl.h:80:1: <LHS trace>
78.   
79.   /* Internal unchecked shorthand; don't use outside this file. */
80. > static inline void packet_forward(PACKET *pkt, size_t len)
81.   {
82.       pkt->curr += len;

ssl/packet_locl.h:80:1: Parameter `pkt->remaining`
    78.   
    79.   /* Internal unchecked shorthand; don't use outside this file. */
    80. > static inline void packet_forward(PACKET *pkt, size_t len)
    81.   {
    82.       pkt->curr += len;

ssl/packet_locl.h:80:1: <RHS trace>
78.   
79.   /* Internal unchecked shorthand; don't use outside this file. */
80. > static inline void packet_forward(PACKET *pkt, size_t len)
81.   {
82.       pkt->curr += len;

ssl/packet_locl.h:80:1: Parameter `len`
    78.   
    79.   /* Internal unchecked shorthand; don't use outside this file. */
    80. > static inline void packet_forward(PACKET *pkt, size_t len)
    81.   {
    82.       pkt->curr += len;

ssl/packet_locl.h:83:5: Binary operation: ([0, +oo] - 4):unsigned64 by call to `PACKET_get_sub_packet` 
    81.   {
    82.       pkt->curr += len;
    83.       pkt->remaining -= len;
              ^
    84.   }
    85.   

static inline void packet_forward(PACKET *pkt, size_t len)
{
    pkt->curr += len;
    pkt->remaining -= len;
}
['static int test_PACKET_get_sub_packet(unsigned char buf[BUF_LEN])\n{\n    PACKET pkt, subpkt;\n    unsigned long i;\n    if (       !PACKET_buf_init(&pkt, buf, BUF_LEN)\n            || !PACKET_get_sub_packet(&pkt, &subpkt, 4)\n            || !PACKET_get_net_4(&subpkt, &i)\n            ||  i != 0x02040608UL\n            ||  PACKET_remaining(&subpkt)\n            || !PACKET_forward(&pkt, BUF_LEN - 8)\n            || !PACKET_get_sub_packet(&pkt, &subpkt, 4)\n            || !PACKET_get_net_4(&subpkt, &i)\n            ||  i != 0xf8fafcfeUL\n            ||  PACKET_remaining(&subpkt)\n            ||  PACKET_get_sub_packet(&pkt, &subpkt, 4)) {\n        fprintf(stderr, "test_PACKET_get_sub_packet() failed\\n");\n        return 0;\n    }\n    return 1;\n}', '__owur static inline int PACKET_buf_init(PACKET *pkt, 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}', '__owur static inline int PACKET_get_sub_packet(PACKET *pkt, PACKET *subpkt,\n                                               size_t len)\n{\n    if (!PACKET_peek_sub_packet(pkt, subpkt, len))\n        return 0;\n    packet_forward(pkt, len);\n    return 1;\n}', 'static inline void packet_forward(PACKET *pkt, size_t len)\n{\n    pkt->curr += len;\n    pkt->remaining -= len;\n}']