Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Commits on Mar 1, 2012
  1. @trast @gitster

    bundle: keep around names passed to add_pending_object()

    trast authored gitster committed
    The 'name' field passed to add_pending_object() is used to later
    deduplicate in object_array_remove_duplicates().
    
    git-bundle had a bug in this area since 18449ab (git-bundle: avoid
    packing objects which are in the prerequisites, 2007-03-08): it passed
    the name of each boundary object in a static buffer.  In other words,
    all that object_array_remove_duplicates() saw was the name of the
    *last* added boundary object.
    
    The recent switch to a strbuf in bc2fed4 (bundle: use a strbuf to scan
    the log for boundary commits, 2012-02-22) made this slightly worse: we
    now free the buffer at the end, so it is not even guaranteed that it
    still points into addressable memory by the time object_array_remove_
    duplicates looks at it.  On the plus side however, it was now
    detectable by valgrind.
    
    The fix is easy: pass a copy of the string to add_pending_object.
    
    Signed-off-by: Thomas Rast <trast@student.ethz.ch>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 23, 2012
  1. @trast @gitster

    bundle: use a strbuf to scan the log for boundary commits

    trast authored gitster committed
    The first part of the bundle header contains the boundary commits, and
    could be approximated by
    
      # v2 git bundle
      $(git rev-list --pretty=oneline --boundary <ARGS> | grep ^-)
    
    git-bundle actually spawns exactly this rev-list invocation, and does
    the grepping internally.
    
    There was a subtle bug in the latter step: it used fgets() with a
    1024-byte buffer.  If the user has sufficiently long subjects (e.g.,
    by not adhering to the git oneline-subject convention in the first
    place), the 'oneline' format can easily overflow the buffer.  fgets()
    then returns the rest of the line in the next call(s).  If one of
    these remaining parts started with '-', git-bundle would mistakenly
    insert it into the bundle thinking it was a boundary commit.
    
    Fix it by using strbuf_getwholeline() instead, which handles arbitrary
    line lengths correctly.
    
    Note that on the receiving side in parse_bundle_header() we were
    already using strbuf_getwholeline_fd(), so that part is safe.
    
    Reported-by: Jannis Pohlmann <jannis.pohlmann@codethink.co.uk>
    Signed-off-by: Thomas Rast <trast@student.ethz.ch>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @trast @gitster

    bundle: put strbuf_readline_fd in strbuf.c with adjustments

    trast authored gitster committed
    The comment even said that it should eventually go there.  While at
    it, match the calling convention and name of the function to the
    strbuf_get*line family.  So it now is strbuf_getwholeline_fd.
    
    Signed-off-by: Thomas Rast <trast@student.ethz.ch>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Something went wrong with that request. Please try again.