Hi,

I believe I have found an off-by-one error in git.

It was discovered using sysctl vm.malloc_conf=S attempting to verify a
git tag from:

https://github.com/fenderq/monstermash

When running:

$ git tag -v v1.2

I would get a segfault.

When I removed the malloc option 'S' it did not segfault.

I narrowed it down to segfault using only "More junking"
MALLOC_OPTIONS=J

With the help of a friend (who wants to remain anonymous), we managed to
narrow the segfault cause down.

This is the patch we created which seems to resolve the issue:

/usr/ports/devel/git/patches/patch-gpg-interface_c

diff -ur a/gpg-interface.c b/gpg-interface.c
--- gpg-interface.c     Sun Feb 24 08:31:46 2019
+++ gpg-interface.c     Mon Jul 15 23:24:03 2019
@@ -116,6 +116,10 @@
        for (line = buf; *line; line = strchrnul(line+1, '\n')) {
                while (*line == '\n')
                        line++;
+
+               /* break out of trailing \n */
+               if (!*line) break;
+
                /* Skip lines that don't start with GNUPG status */
                if (!skip_prefix(line, "[GNUPG:] ", &line))
                        continue;

Reply via email to