summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-05-19 23:59:38 +0200
committermanuel <manuel@mausz.at>2020-05-19 23:59:38 +0200
commit0f0e11b3d64ad562016d5c21dadbce74cc70c5f9 (patch)
tree02552111ef549609ace513f08325f4f3c7c2c4ea
parentf2ef25deb1aa356d41cdd3f6e46d9a68c48bfce0 (diff)
downloadqmail-0f0e11b3d64ad562016d5c21dadbce74cc70c5f9.tar.gz
qmail-0f0e11b3d64ad562016d5c21dadbce74cc70c5f9.tar.bz2
qmail-0f0e11b3d64ad562016d5c21dadbce74cc70c5f9.zip
Make sure to limit max alloc size
see https://www.qualys.com/2020/05/19/cve-2005-1513/remote-code-execution-qmail.txt
-rw-r--r--alloc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/alloc.c b/alloc.c
index 48a109b..11fe431 100644
--- a/alloc.c
+++ b/alloc.c
@@ -1,3 +1,4 @@
1#include <limits.h>
1#include "alloc.h" 2#include "alloc.h"
2#include "error.h" 3#include "error.h"
3#include <stdlib.h> 4#include <stdlib.h>
@@ -14,6 +15,10 @@ static unsigned int avail = SPACE; /* multiple of ALIGNMENT; 0<=avail<=SPACE */
14unsigned int n; 15unsigned int n;
15{ 16{
16 char *x; 17 char *x;
18 if (n >= (INT_MAX >> 3)) {
19 errno = error_nomem;
20 return 0;
21 }
17 n = ALIGNMENT + n - (n & (ALIGNMENT - 1)); /* XXX: could overflow */ 22 n = ALIGNMENT + n - (n & (ALIGNMENT - 1)); /* XXX: could overflow */
18 if (n <= avail) { avail -= n; return space + avail; } 23 if (n <= avail) { avail -= n; return space + avail; }
19 x = malloc(n); 24 x = malloc(n);