git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[BUG] remote.c/match_explicit() ... NULL pointer dereferenciation (git 1.5.3.4)

From
MFMelchior FRANZ <mfranz@aon.at>
Date
Oct 30, 2007, 10:44 UTC
Message-ID
<200710301144.32528@rk-nord.at>
Hi,

I'm mucking around with git while implementing a simple, flat CVS gateway. For tests I created a local remote clone via "git remote add -f -t master -m master origin /local/path" (as described on the git-remote man-page). When running a (wrong) command like "git push origin foo", whereby "foo" is nowhere defined in the refspec list:

  [remote "origin"]
          url = /local/path
          fetch = +refs/heads/master:refs/remotes/origin/master
          push = +master:refs/heads/sync

then git-send-pack segfaults in remote.c/count_refspec_match in the strlen() function, because "pattern" contains garbage.

And this is because in match_explicit() we have these lines:
        if (!matched_src)
                errs = 1;
        if (dst_value == NULL)
                dst_value = matched_src->name;
                                           <<- gdb prints from here

and with the unknown refspec "foo" both dst_value and matched_src are zero:

  (gdb) print dst_value
  $1 = 0x0
  (gdb) print *rs
  $2 = {
    force = 0,
    pattern = 0,
    src = 0x808d680 "foo",
    dst = 0x0
  }
  (gdb) print matched_src
  $3 = (struct ref *) 0x0
  (gdb) print dst_value
  $4 = 0x34 <Address 0x34 out of bounds>

No idea, why the NULL-pointer dereferenciation doesn't segfault right away, but assigns 0x34 to dst_value. Compiler bug?

m.
Spec:
  Linux 2.6.23.1  x86/P4
  gcc 4.2.1 (SUSE Linux)   (openSuSE 10.3)
  libc 2.6.1 (20070803)
  git 1.5.3.4  (compiled with -g -O0)
Next: Junio C Hamano
Message 1 of 2 in “[BUG] remote.c/match_explicit() ... NULL pointer dereferenciation (git 1.5.3.4)”
  1. Melchior FRANZOct 30, 2007
  2. Junio C HamanoOct 30, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.