[CRIU] [PATCH 5/8] cgroup: don't give not null terminated string into strtoll()

Andrey Vagin avagin at openvz.org
Fri Oct 31 07:50:47 PDT 2014


CID 73345 (#1 of 1): String not null terminated (STRING_NULL)
2. string_null_argument: Function fread does not terminate string *buf. [Note: The source code implementation of the function has been overridden by a builtin model.]

Cc: Tycho Andersen <tycho.andersen at canonical.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cgroup.c b/cgroup.c
index fb5c8ac..66f0bcc 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -316,7 +316,7 @@ static int read_cgroup_prop(struct cgroup_prop *property, const char *fullpath)
 	}
 
 	memset(buf, 0, sizeof(buf));
-	if (fread(buf, sizeof(buf), 1, f) != 1) {
+	if (fread(buf, sizeof(buf) - 1, 1, f) != 1) {
 		if (!feof(f)) {
 			pr_err("Failed scanning %s\n", fullpath);
 			fclose(f);
-- 
1.9.3



More information about the CRIU mailing list