[RFC/PATCH 0/8] Re: bug: git-bundle create foo --stdin -> segfault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Joey Hess wrote:

> I noticed that git bundle --stdin actually attempts to read from stdin
> past EOF.

Patch 5 below fixes that.  Sadly it is not the whole story and I had
to introduce a memory leak for all users of --stdin to make
‘bundle --stdin’ actually work (patch 6).

In the case of bundle --stdin, I think the leak is unavoidable, while
in general, I suspect a parameter is needed to allow the caller to
indicate whether the leak is needed (analogous to save_commit_buffer).

The rest of the patches should be comparatively pleasant.

Patches 1, 3, and 4 give various parts of bundle creation their own
functions, to make the code easier to digest;

Patch 2 teaches the basis discovery code (which currently forks a
rev-list --boundary process) to use the revision walker directly, to
prepare for patch 5.

Patch 5 looked like it would be the main point of the series: it saves
the list of revs including those read from stdin and resets the
revision walker after the boundary is found.  This way, stdin is only
read once and the underlying logic of the revision walk does not need
to be changed significantly.

Even with patch 5, bundle --stdin still finds no revisions to read.
The problem: to write the table of contents, the name passed on the
command line for each ref is needed.  Unfortunately, names passed
through stdin are kept in a temporary buffer and then freed; the
random gibberish read instead does not look like a meaningful ref
name, so no valid toc entries are found.

Patch 6 fixes this, at the cost of a memory leak.  Suggestions for
avoiding the leak would of course be welcome.

Patch 7 adopts a similar “fix” in a context where it is not needed.
This is just for illustration.

Patch 8 is an unrelated enhancement that came along the way.

Thanks to Joey for the report and Johannes for suggestions for fixing
it.

Thoughts?  Tests to add?
Jonathan Nieder (8):
  bundle: split basis discovery into its own function
  bundle: use libified rev-list --boundary
  bundle: split body of list_prerequisites() loop into its own function
  bundle: split table of contents output into its own function
  bundle: reuse setup_revisions result
  revision: Keep ref names after reading them from stdin
  bundle: Keep names of basis refs after discovery
  bundle_create: Do not exit when given no revs to bundle

 bundle.c          |  172 ++++++++++++++++++++++++++++++++++-------------------
 revision.c        |    2 +-
 t/t5704-bundle.sh |    4 +-
 3 files changed, 113 insertions(+), 65 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]