]> wimlib.net Git - wimlib/blobdiff - include/wimlib/header.h
Prevent huge memory allocations from fuzzed header fields
[wimlib] / include / wimlib / header.h
index 894bd22591897491f2089ce75c4bd0dacb64939f..7ef677369f9a039f8d44a96160dd94dca29e95e9 100644 (file)
@@ -112,7 +112,12 @@ struct wim_header_disk {
        /* +0xd0 (208)  */
 } _packed_attribute;
 
-#define MAX_IMAGES (((INT_MAX < INT32_MAX) ? INT_MAX : INT32_MAX) - 1)
+/*
+ * Arbitrarily limit the maximum number of images to 65535, to prevent huge
+ * memory allocations when processing fuzzed files.  This can be increased if
+ * ever needed (up to INT_MAX - 1).
+ */
+#define MAX_IMAGES     65535
 
 /* In-memory representation of a WIM header.  See `struct wim_header_disk' for
  * field descriptions.  */