summaryrefslogtreecommitdiffstats
path: root/ssl/packet_locl.h
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2015-12-30 14:56:59 +0100
committerRichard Levitte <levitte@openssl.org>2015-12-30 14:56:59 +0100
commit36830ecac7a5ff1935e465d6e95f32d72e614a56 (patch)
treee09f9c2b4aaaa289a44dccaa0321bf684086262b /ssl/packet_locl.h
parent3dc9589cc84735a8478b34a121e648d1cadfb715 (diff)
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>
Diffstat (limited to 'ssl/packet_locl.h')
-rw-r--r--ssl/packet_locl.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/ssl/packet_locl.h b/ssl/packet_locl.h
index 39fac55bb4..48a5f3d7dc 100644
--- a/ssl/packet_locl.h
+++ b/ssl/packet_locl.h
@@ -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;