Simplify the overflow checks in WPACKET_allocate_bytes()

Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
Matt Caswell 2016-09-08 23:08:53 +01:00
parent 9bf85bf9c5
commit 6ae4f5e087

View 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) {