mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
SIZE_MAX doesn't exist everywhere, supply an alternative
SIZE_MAX is a great macro, and does unfortunately not exist everywhere. Since we check against half of it, using bitwise shift to calculate the value of half SIZE_MAX should be safe enough. Reviewed-by: Tim Hudson <tjh@openssl.org>
This commit is contained in:
parent
3dc9589cc8
commit
36830ecac7
@ -111,8 +111,13 @@ __owur static ossl_inline int PACKET_buf_init(PACKET *pkt, unsigned char *buf,
|
||||
size_t len)
|
||||
{
|
||||
/* Sanity check for negative values. */
|
||||
#ifdef SIZE_MAX
|
||||
if (len > (size_t)(SIZE_MAX / 2))
|
||||
return 0;
|
||||
#else
|
||||
if (len > ((size_t)2 << (sizeof(size_t) * 8 - 1)))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
pkt->curr = buf;
|
||||
pkt->remaining = len;
|
||||
|
Loading…
Reference in New Issue
Block a user