Instead of a local hack, implement SIZE_MAX in numbers.h if it's missing
authorRichard Levitte <levitte@openssl.org>
Sat, 2 Jan 2016 18:19:00 +0000 (19:19 +0100)
committerRichard Levitte <levitte@openssl.org>
Sat, 2 Jan 2016 20:11:02 +0000 (21:11 +0100)
Reviewed-by: Stephen Henson <steve@openssl.org>
include/internal/numbers.h
ssl/packet_locl.h

index 1f79ef7..da06dab 100644 (file)
 #  define UINT64_MAX __MAXUINT__(uint64_t)
 # endif
 
+# ifndef SIZE_MAX
+#  define SIZE_MAX __MAXUINT__(size_t)
+# endif
+
 #endif
 
index 48a5f3d..ed7c1ca 100644 (file)
@@ -65,6 +65,8 @@
 # include <openssl/crypto.h>
 # include <openssl/e_os2.h>
 
+# include "internal/numbers.h"
+
 # ifdef __cplusplus
 extern "C" {
 # endif
@@ -111,13 +113,8 @@ __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;