[Linux-cachefs] [PATCH 03/11] Fixing null reference for malformed kernel status output.

David Howells dhowells at redhat.com
Mon Jan 25 14:52:58 UTC 2016


From: John Snow <jsnow at redhat.com>

In certain cases, a NULL may be passed along to string library functions.
Not anymore!

Signed-off-by: John Snow <jsnow at redhat.com>
Signed-off-by: David Howells <dhowells at redhat.com>
---

 cachefilesd.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cachefilesd.c b/cachefilesd.c
index 7059876..72525bc 100644
--- a/cachefilesd.c
+++ b/cachefilesd.c
@@ -759,8 +759,12 @@ static void read_cache_state(void)
 			*next++ = '\0';
 
 		arg = strchr(tok, '=');
-		if (arg)
+		if (arg) {
 			*arg++ = '\0';
+		} else {
+			debug(0, "Warning: malformed output from kernel, missing arg to [%s]", tok);
+			continue;
+		}
 
 		if (strcmp(tok, "cull") == 0)
 			cull = strtoul(arg, NULL, 0);




More information about the Linux-cachefs mailing list