Browse Source

tools: hv: Check retrun value of strchr call

Check return value of strchr call and dereference it only if it is
not NULL.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Acked-by:  K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Tomas Hozza 12 years ago
parent
commit
f14e600a3b
1 changed files with 3 additions and 1 deletions
  1. 3 1
      tools/hv/hv_kvp_daemon.c

+ 3 - 1
tools/hv/hv_kvp_daemon.c

@@ -765,7 +765,9 @@ static void kvp_process_ipconfig_file(char *cmd,
 			break;
 
 		x = strchr(p, '\n');
-		*x = '\0';
+		if (x)
+			*x = '\0';
+
 		strcat(config_buf, p);
 		strcat(config_buf, ";");
 	}