Avoid undefined behaviour in PACKET_buf_init
[openssl.git] / ssl / packet_locl.h
index 507d64f8c41eb9bdce78be4763599b15b788a4bc..cb61a93ad3deda4e08ce8b47db9c8029e45d9a73 100644 (file)
@@ -111,7 +111,7 @@ __owur static inline int PACKET_buf_init(PACKET *pkt, unsigned char *buf,
                                          size_t len)
 {
     /* Sanity check for negative values. */
-    if (buf + len < buf)
+    if (len > (size_t)(SIZE_MAX / 2))
         return 0;
 
     pkt->curr = buf;