Re: [PATCH 0/17] removing questionable uses of git_path

2015-08-15 Thread Duy Nguyen
On Mon, Aug 10, 2015 at 4:27 PM, Jeff King wrote: > The problem is that git_path uses a static buffer that gets overwritten > by subsequent calls. resolve_ref() was in the same boat, then we renamed it to resolve_ref_unsafe(), I believe with an intention to eventually kill it. But it lives on any

Re: [PATCH 0/17] removing questionable uses of git_path

2015-08-10 Thread Jeff King
On Mon, Aug 10, 2015 at 10:31:32AM -0700, Junio C Hamano wrote: > Jeff King writes: > > > The problem is that git_path uses a static buffer that gets overwritten > > by subsequent calls. > > As the rotating static buffer pattern used in get_pathname() was > modeled after sha1_to_hex(), we have

Re: [PATCH 0/17] removing questionable uses of git_path

2015-08-10 Thread Junio C Hamano
Jeff King writes: > The problem is that git_path uses a static buffer that gets overwritten > by subsequent calls. As the rotating static buffer pattern used in get_pathname() was modeled after sha1_to_hex(), we have the same issue there. They are troubles waiting to happen unless the callers a

Re: [PATCH 0/17] removing questionable uses of git_path

2015-08-10 Thread Michael Haggerty
On 08/10/2015 11:27 AM, Jeff King wrote: > [...] The problem is that git_path uses a static buffer that gets overwritten > by subsequent calls. [...] > > [01/17]: cache.h: clarify documentation for git_path, et al > [02/17]: cache.h: complete set of git_path_submodule helpers > [03/17]: t570

[PATCH 0/17] removing questionable uses of git_path

2015-08-10 Thread Jeff King
Recently Michael and I were working on a patch series (not yet published), which did something like: const char *path = git_path("foo"); ... do stuff with path ... for_each_ref(some_callback, NULL); ... do some other stuff ... unlink(path); Clever readers may have spotted the bug i