core: check for overflow when handling scaled MemoryLimit= settings
authorLennart Poettering <lennart@poettering.net>
Fri, 22 Jul 2016 13:30:23 +0000 (15:30 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Jul 2016 13:33:13 +0000 (15:33 +0200)
Just in case...

src/core/load-fragment.c

index cd7bf9c..ae306de 100644 (file)
@@ -2823,8 +2823,8 @@ int config_parse_memory_limit(
                 } else
                         bytes = physical_memory_scale(r, 100U);
 
-                if (bytes < 1) {
-                        log_syntax(unit, LOG_ERR, filename, line, 0, "Memory limit '%s' too small. Ignoring.", rvalue);
+                if (bytes <= 0 || bytes >= UINT64_MAX) {
+                        log_syntax(unit, LOG_ERR, filename, line, 0, "Memory limit '%s' out of range. Ignoring.", rvalue);
                         return 0;
                 }
         }