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 <quic_eberman@quicinc.com>
This commit is contained in:
Elliot Berman 2022-04-06 08:35:31 -07:00
parent c1bc6a5119
commit ff156e05e3

View File

@ -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);