From 6ae4f5e087d204e02a5dc88ea905cca9d144a30d Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Thu, 8 Sep 2016 23:08:53 +0100 Subject: [PATCH] Simplify the overflow checks in WPACKET_allocate_bytes() Reviewed-by: Rich Salz --- ssl/packet.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ssl/packet.c b/ssl/packet.c index 4823b16a6e..e75193ddc3 100644 --- a/ssl/packet.c +++ b/ssl/packet.c @@ -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) { -- 2.40.0