Explorar o código

run_command: strlen() will not function if string is not null terminated

Aaron Marcher %!s(int64=9) %!d(string=hai) anos
pai
achega
8a29374783
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      slstatus.c

+ 1 - 1
slstatus.c

@@ -426,7 +426,7 @@ run_command(const char *cmd)
 	}
 	fgets(buf, sizeof(buf), fp);
 	pclose(fp);
-	buf[strlen(buf)] = '\0';
+	buf[sizeof(buf)] = '\0';
 
 	if ((nlptr = strstr(buf, "\n")) != NULL) {
 		nlptr[0] = '\0';