]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fileio: fix MIN/MAX mixup (#3896)
authorVito Caputo <vcaputo@gnugeneration.com>
Fri, 5 Aug 2016 04:09:23 +0000 (21:09 -0700)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 5 Aug 2016 04:09:23 +0000 (00:09 -0400)
The intention is to clamp the value to READ_FULL_BYTES_MAX, which
would be the minimum of the two.

src/basic/fileio.c

index c18ac39e03958d57a104a1782d8d189b8e6d5496..588eacd77cd1e4d36202f860f51bf762a8adf7be 100644 (file)
@@ -271,7 +271,7 @@ int read_full_stream(FILE *f, char **contents, size_t *size) {
                 if (n >= READ_FULL_BYTES_MAX)
                         return -E2BIG;
 
-                n = MAX(n * 2, READ_FULL_BYTES_MAX);
+                n = MIN(n * 2, READ_FULL_BYTES_MAX);
         }
 
         buf[l] = 0;