[lxc-devel] [lxcfs/master] fix offsets for memory.stat parsing

Fabian-Gruenbichler on Github lxc-bot at linuxcontainers.org
Wed Oct 19 07:30:27 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 666 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161019/fce3581c/attachment.bin>
-------------- next part --------------
From 375bb1c8a08806cf3cccbf52648795e3c856df5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= <f.gruenbichler at proxmox.com>
Date: Wed, 19 Oct 2016 09:06:59 +0200
Subject: [PATCH] fix offsets for memory.stat parsing

---
 bindings.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/bindings.c b/bindings.c
index 228dad7..c95cc6e 100644
--- a/bindings.c
+++ b/bindings.c
@@ -2953,22 +2953,22 @@ static void parse_memstat(char *memstat, unsigned long *cached,
 
 	while (*memstat) {
 		if (startswith(memstat, "cache")) {
-			sscanf(memstat + 11, "%lu", cached);
+			sscanf(memstat + sizeof("cache"), "%lu", cached);
 			*cached /= 1024;
 		} else if (startswith(memstat, "active_anon")) {
-			sscanf(memstat + 11, "%lu", active_anon);
+			sscanf(memstat + sizeof("active_anon"), "%lu", active_anon);
 			*active_anon /= 1024;
 		} else if (startswith(memstat, "inactive_anon")) {
-			sscanf(memstat + 11, "%lu", inactive_anon);
+			sscanf(memstat + sizeof("inactive_anon"), "%lu", inactive_anon);
 			*inactive_anon /= 1024;
 		} else if (startswith(memstat, "active_file")) {
-			sscanf(memstat + 11, "%lu", active_file);
+			sscanf(memstat + sizeof("active_file"), "%lu", active_file);
 			*active_file /= 1024;
 		} else if (startswith(memstat, "inactive_file")) {
-			sscanf(memstat + 11, "%lu", inactive_file);
+			sscanf(memstat + sizeof("inactive_file"), "%lu", inactive_file);
 			*inactive_file /= 1024;
 		} else if (startswith(memstat, "unevictable")) {
-			sscanf(memstat + 11, "%lu", unevictable);
+			sscanf(memstat + sizeof("unevictable"), "%lu", unevictable);
 			*unevictable /= 1024;
 		}
 		eol = strchr(memstat, '\n');


More information about the lxc-devel mailing list