1. 21 2月, 2013 9 次提交
    • J
      pkt-line: move a misplaced comment · e1485428
      Jeff King 提交于
      The comment describing the packet writing interface was
      originally written above packet_write, but migrated to be
      above safe_write in f3a3214e, probably because it is meant to
      generally describe the packet writing interface and not a
      single function. Let's move it into the header file, where
      users of the interface are more likely to see it.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e1485428
    • J
      write_or_die: raise SIGPIPE when we get EPIPE · 756e676c
      Jeff King 提交于
      The write_or_die function will always die on an error,
      including EPIPE. However, it currently treats EPIPE
      specially by suppressing any error message, and by exiting
      with exit code 0.
      
      Suppressing the error message makes some sense; a pipe death
      may just be a sign that the other side is not interested in
      what we have to say. However, exiting with a successful
      error code is not a good idea, as write_or_die is frequently
      used in cases where we want to be careful about having
      written all of the output, and we may need to signal to our
      caller that we have done so (e.g., you would not want a push
      whose other end has hung up to report success).
      
      This distinction doesn't typically matter in git, because we
      do not ignore SIGPIPE in the first place. Which means that
      we will not get EPIPE, but instead will just die when we get
      a SIGPIPE. But it's possible for a default handler to be set
      by a parent process, or for us to add a callsite inside one
      of our few SIGPIPE-ignoring blocks of code.
      
      This patch converts write_or_die to actually raise SIGPIPE
      when we see EPIPE, rather than exiting with zero. This
      brings the behavior in line with the "normal" case that we
      die from SIGPIPE (and any callers who want to check why we
      died will see the same thing). We also give the same
      treatment to other related functions, including
      write_or_whine_pipe and maybe_flush_or_die.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      756e676c
    • J
      upload-archive: use argv_array to store client arguments · 090fd4fe
      Jeff King 提交于
      The current parsing scheme for upload-archive is to pack
      arguments into a fixed-size buffer, separated by NULs, and
      put a pointer to each argument in the buffer into a
      fixed-size argv array.
      
      This works fine, and the limits are high enough that nobody
      reasonable is going to hit them, but it makes the code hard
      to follow.  Instead, let's just stuff the arguments into an
      argv_array, which is much simpler. That lifts the "all
      arguments must fit inside 4K together" limit.
      
      We could also trivially lift the MAX_ARGS limitation (in
      fact, we have to keep extra code to enforce it). But that
      would mean a client could force us to allocate an arbitrary
      amount of memory simply by sending us "argument" lines. By
      limiting the MAX_ARGS, we limit an attacker to about 4
      megabytes (64 times a maximum 64K packet buffer). That may
      sound like a lot compared to the 4K limit, but it's not a
      big deal compared to what git-archive will actually allocate
      while working (e.g., to load blobs into memory). The
      important thing is that it is bounded.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      090fd4fe
    • J
      upload-archive: do not copy repo name · 6379dd05
      Jeff King 提交于
      According to the comment, enter_repo will modify its input.
      However, this has not been the case since 1c64b48e
      (enter_repo: do not modify input, 2011-10-04). Drop the
      now-useless copy.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6379dd05
    • J
      send-pack: prefer prefixcmp over memcmp in receive_status · 8f9e3e49
      Jeff King 提交于
      This code predates prefixcmp, so it used memcmp along with
      static sizes. Replacing these memcmps with prefixcmp makes
      the code much more readable, and the lack of static sizes
      will make refactoring it in future patches simpler.
      
      Note that we used to be unnecessarily liberal in parsing the
      "unpack" status line, and would accept "unpack ok\njunk". No
      version of git has ever produced that, and it violates the
      BNF in Documentation/technical/pack-protocol.txt. Let's take
      this opportunity to tighten the check by converting the
      prefix comparison into a strcmp.
      
      While we're in the area, let's also fix a vague error
      message that does not follow our usual conventions (it
      writes directly to stderr and does not use the "error:"
      prefix).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8f9e3e49
    • J
      fetch-pack: fix out-of-bounds buffer offset in get_ack · 030e9dd6
      Jeff King 提交于
      When we read acks from the remote, we expect either:
      
        ACK <sha1>
      
      or
      
        ACK <sha1> <multi-ack-flag>
      
      We parse the "ACK <sha1>" bit from the line, and then start
      looking for the flag strings at "line+45"; if we don't have
      them, we assume it's of the first type.  But if we do have
      the first type, then line+45 is not necessarily inside our
      string at all!
      
      It turns out that this works most of the time due to the way
      we parse the packets. They should come in with a newline,
      and packet_read puts an extra NUL into the buffer, so we end
      up with:
      
        ACK <sha1>\n\0
      
      with the newline at offset 44 and the NUL at offset 45. We
      then strip the newline, putting a NUL at offset 44. So
      when we look at "line+45", we are looking past the end of
      our string; but it's OK, because we hit the terminator from
      the original string.
      
      This breaks down, however, if the other side does not
      terminate their packets with a newline. In that case, our
      packet is one character shorter, and we start looking
      through uninitialized memory for the flag. No known
      implementation sends such a packet, so it has never come up
      in practice.
      
      This patch tightens the check by looking for a short,
      flagless ACK before trying to parse the flag.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      030e9dd6
    • J
      upload-pack: remove packet debugging harness · 97a83fa8
      Jeff King 提交于
      If you set the GIT_DEBUG_SEND_PACK environment variable,
      upload-pack will dump lines it receives in the receive_needs
      phase to a descriptor. This debugging harness is a strict
      subset of what GIT_TRACE_PACKET can do. Let's just drop it
      in favor of that.
      
      A few tests used GIT_DEBUG_SEND_PACK to confirm which
      objects get sent; we have to adapt them to the new output
      format.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      97a83fa8
    • J
      upload-pack: do not add duplicate objects to shallow list · e58e57e4
      Jeff King 提交于
      When the client tells us it has a shallow object via
      "shallow <sha1>", we make sure we have the object, mark it
      with a flag, then add it to a dynamic array of shallow
      objects. This means that a client can get us to allocate
      arbitrary amounts of memory just by flooding us with shallow
      lines (whether they have the objects or not). You can
      demonstrate it easily with:
      
        yes '0035shallow e83c5163' |
        git-upload-pack git.git
      
      We already protect against duplicates in want lines by
      checking if our flag is already set; let's do the same thing
      here. Note that a client can still get us to allocate some
      amount of memory by marking every object in the repo as
      "shallow" (or "want"). But this at least bounds it with the
      number of objects in the repository, which is not under the
      control of an upload-pack client.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e58e57e4
    • J
      upload-pack: use get_sha1_hex to parse "shallow" lines · b7b02170
      Jeff King 提交于
      When we receive a line like "shallow <sha1>" from the
      client, we feed the <sha1> part to get_sha1. This is a
      mistake, as the argument on a shallow line is defined by
      Documentation/technical/pack-protocol.txt to contain an
      "obj-id".  This is never defined in the BNF, but it is clear
      from the text and from the other uses that it is meant to be
      a hex sha1, not an arbitrary identifier (and that is what
      fetch-pack has always sent).
      
      We should be using get_sha1_hex instead, which doesn't allow
      the client to request arbitrary junk like "HEAD@{yesterday}".
      Because this is just marking shallow objects, the client
      couldn't actually do anything interesting (like fetching
      objects from unreachable reflog entries), but we should keep
      our parsing tight to be on the safe side.
      
      Because get_sha1 is for the most part a superset of
      get_sha1_hex, in theory the only behavior change should be
      disallowing non-hex object references. However, there is
      one interesting exception: get_sha1 will only parse
      a 40-character hex sha1 if the string has exactly 40
      characters, whereas get_sha1_hex will just eat the first 40
      characters, leaving the rest. That means that current
      versions of git-upload-pack will not accept a "shallow"
      packet that has a trailing newline, even though the protocol
      documentation is clear that newlines are allowed (even
      encouraged) in non-binary parts of the protocol.
      
      This never mattered in practice, though, because fetch-pack,
      contrary to the protocol documentation, does not include a
      newline in its shallow lines. JGit follows its lead (though
      it correctly is strict on the parsing end about wanting a
      hex object id).
      
      We do not adjust fetch-pack to send newlines here, as it
      would break communication with older versions of git (and
      there is no actual benefit to doing so, except for
      consistency with other parts of the protocol).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b7b02170
  2. 18 2月, 2013 6 次提交
    • J
      Git 1.8.2-rc0 · 004825d3
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      004825d3
    • J
      Merge branch 'jc/hidden-refs' · ce735bf7
      Junio C Hamano 提交于
      Allow the server side to redact the refs/ namespace it shows to the
      client.
      
      Will merge to 'master'.
      
      * jc/hidden-refs:
        upload/receive-pack: allow hiding ref hierarchies
        upload-pack: simplify request validation
        upload-pack: share more code
      ce735bf7
    • J
      Merge branch 'mp/diff-algo-config' · abea4dc7
      Junio C Hamano 提交于
      Add diff.algorithm configuration so that the user does not type
      "diff --histogram".
      
      * mp/diff-algo-config:
        diff: Introduce --diff-algorithm command line option
        config: Introduce diff.algorithm variable
        git-completion.bash: Autocomplete --minimal and --histogram for git-diff
      abea4dc7
    • J
      Merge branch 'mw/bash-prompt-show-untracked-config' · adbbc6f2
      Junio C Hamano 提交于
      Allows skipping the untracked check GIT_PS1_SHOWUNTRACKEDFILES
      asks for the git-prompt (in contrib/) per repository.
      
      * mw/bash-prompt-show-untracked-config:
        t9903: add extra tests for bash.showDirtyState
        t9903: add tests for bash.showUntrackedFiles
        shell prompt: add bash.showUntrackedFiles option
      adbbc6f2
    • J
      Merge branch 'jk/rebase-i-comment-char' · 00abd715
      Junio C Hamano 提交于
      Finishing touches to the earlier core.commentchar topic to cover
      "rebase -i" as well.
      
      * jk/rebase-i-comment-char:
        rebase -i: respect core.commentchar
      00abd715
    • J
      Merge branch 'jk/read-commit-buffer-data-after-free' · d04f998b
      Junio C Hamano 提交于
      "git log --grep=<pattern>" used to look for the pattern in literal
      bytes of the commit log message and ignored the log-output encoding.
      
      * jk/read-commit-buffer-data-after-free:
        log: re-encode commit messages before grepping
      d04f998b
  3. 16 2月, 2013 1 次提交
  4. 15 2月, 2013 20 次提交
  5. 14 2月, 2013 4 次提交