From: Steven Roberts Date: Tue, 16 Jul 2019 18:47:37 +0000 (-0700) Subject: gpg-interface: do not scan past the end of buffer X-Git-Tag: v2.23.0-rc0~13^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/64c45dc72ef039215f23d1b8f077dd6f9f254d38 gpg-interface: do not scan past the end of buffer If the GPG output ends with trailing blank lines, after skipping them over inside the loop to find the terminating NUL at the end, the loop ends up looking for the next line, starting past the end. Signed-off-by: Steven Roberts Signed-off-by: Junio C Hamano --- diff --git a/gpg-interface.c b/gpg-interface.c index 8ed274533f..d60115ca40 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -116,6 +116,9 @@ static void parse_gpg_output(struct signature_check *sigc) for (line = buf; *line; line = strchrnul(line+1, '\n')) { while (*line == '\n') line++; + if (!*line) + break; + /* Skip lines that don't start with GNUPG status */ if (!skip_prefix(line, "[GNUPG:] ", &line)) continue;