From: Matt Caswell Date: Thu, 8 Sep 2016 22:08:53 +0000 (+0100) Subject: Simplify the overflow checks in WPACKET_allocate_bytes() X-Git-Tag: OpenSSL_1_1_1-pre1~3560 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ae4f5e087d204e02a5dc88ea905cca9d144a30d;p=openssl Simplify the overflow checks in WPACKET_allocate_bytes() Reviewed-by: Rich Salz --- 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) {