gpg-interface: do not scan past the end of buffer
authorSteven Roberts <fenderq@gmail.com>
Tue, 16 Jul 2019 18:47:37 +0000 (11:47 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Jul 2019 19:15:12 +0000 (12:15 -0700)
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 <sroberts@fenderq.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gpg-interface.c
index 8ed274533f87198a74a3660809c25932fa43124a..d60115ca404edfedc492c55e5bc0f22fe0eaa5a2 100644 (file)
@@ -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;