Simplify the overflow checks in WPACKET_allocate_bytes()
authorMatt Caswell <matt@openssl.org>
Thu, 8 Sep 2016 22:08:53 +0000 (23:08 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 13 Sep 2016 08:41:21 +0000 (09:41 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
ssl/packet.c

index 4823b16a6e3157b8dbda5b9cecb06d38570699db..e75193ddc3202bb6afbc7a3e0f10d81dcbe7e8db 100644 (file)
@@ -16,10 +16,7 @@ int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
     if (pkt->subs == NULL || len == 0)
         return 0;
 
-    if (SIZE_MAX - pkt->written < len)
-        return 0;
-
-    if (pkt->written + len > pkt->maxsize)
+    if (pkt->maxsize - pkt->written < len)
         return 0;
 
     if (pkt->buf->length - pkt->written < len) {