Procházet zdrojové kódy

cc-wrapper: Resolve possible buffer overflow

buf needs to null-terminated line processing uses strcmp and regex. Thus,
we should only read sizeof(buf) - 1 bytes to ensure we can
null-terminate the buffer.

Change-Id: I1f424b8097318eade58723818bfa154c3115d37e
Signed-off-by: Elliot Berman <[email protected]>
Elliot Berman před 3 roky
rodič
revize
ff156e05e3
1 změnil soubory, kde provedl 1 přidání a 1 odebrání
  1. 1 1
      scripts/basic/cc-wrapper.c

+ 1 - 1
scripts/basic/cc-wrapper.c

@@ -143,7 +143,7 @@ int main(int argc, char **argv)
 		goto done;
 	}
 
-	while ((len = read(pipes[0], buf, sizeof(buf))) > 0) {
+	while ((len = read(pipes[0], buf, sizeof(buf) - 1)) > 0) {
 		char *next = buf;
 
 		write(STDERR_FILENO, buf, len);