]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
criu.c: protect from buffer overrun of version in fscanf()
authorWim Coekaerts <wim.coekaerts@oracle.com>
Sun, 27 Dec 2015 17:29:10 +0000 (09:29 -0800)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 4 Jan 2016 17:52:26 +0000 (12:52 -0500)
while highly unlikely to happen...
char version[1024];

fscanf(.. %[1024] .., version  );

should leave room for null termination

Signed-off-by: Wim Coekaerts <wim.coekaerts@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/criu.c

index 0a0392f6dc5e6b0eb10a6a468a4e97e3f31f92bc..6ef49058982b80f28fcadf102c7f9be34311cfae 100644 (file)
@@ -315,7 +315,7 @@ static bool criu_version_ok()
                        return false;
                }
 
-               if (fscanf(f, "Version: %1024[^\n]s", version) != 1)
+               if (fscanf(f, "Version: %1023[^\n]s", version) != 1)
                        goto version_error;
 
                if (fgetc(f) != '\n')
@@ -324,7 +324,7 @@ static bool criu_version_ok()
                if (strcmp(version, CRIU_VERSION) >= 0)
                        goto version_match;
 
-               if (fscanf(f, "GitID: v%1024[^-]s", version) != 1)
+               if (fscanf(f, "GitID: v%1023[^-]s", version) != 1)
                        goto version_error;
 
                if (fgetc(f) != '-')