]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: config: count memory limits on 64 bits, not 32
authorWilly Tarreau <w@1wt.eu>
Thu, 29 Oct 2015 09:42:55 +0000 (10:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 29 Oct 2015 09:42:55 +0000 (10:42 +0100)
It was accidently discovered that limiting haproxy to 5000 MB leads to
an effective limit of 904 MB. This is because the computation for the
size limit is performed by multiplying rlimit_memmax by 1048576, and
doing so causes the operation to be performed on an int instead of a
long or long long. Just switch to 1048576ULL as is done at other places
to fix this.

This bug affects all supported versions, the backport is desired, though
it rarely affects users since few people apply memory limits.

src/haproxy.c

index 3b0d14df61b371dc10f06ce5b6db0b29fb73a054..93423a9b0971f37c34eb7b0023cd1c3f78db235f 100644 (file)
@@ -1642,7 +1642,7 @@ int main(int argc, char **argv)
 
        if (global.rlimit_memmax) {
                limit.rlim_cur = limit.rlim_max =
-                       global.rlimit_memmax * 1048576 / global.nbproc;
+                       global.rlimit_memmax * 1048576ULL / global.nbproc;
 #ifdef RLIMIT_AS
                if (setrlimit(RLIMIT_AS, &limit) == -1) {
                        Warning("[%s.main()] Cannot fix MEM limit to %d megs.\n",