Re: [PATCH v3 05/10] abspath: convert real_path_internal() to strbuf

2014-07-29 Thread Junio C Hamano
René Scharfe l@web.de writes: Next call to the function invalidates the return value the last caller received feels like playing with fire. Most existing callers are safe in that the first thing they do to the returned string is xstrdup() it, but we would need to check all the other

[PATCH v3 05/10] abspath: convert real_path_internal() to strbuf

2014-07-28 Thread René Scharfe
Use strbuf instead of fixed-sized buffers in real_path() in order to avoid the size limitations of the latter. Signed-off-by: Rene Scharfe l@web.de --- abspath.c | 69 +++ 1 file changed, 25 insertions(+), 44 deletions(-) diff

Re: [PATCH v3 05/10] abspath: convert real_path_internal() to strbuf

2014-07-28 Thread Jeff King
On Mon, Jul 28, 2014 at 08:28:30PM +0200, René Scharfe wrote: static const char *real_path_internal(const char *path, int die_on_error) { - static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1]; + static struct strbuf sb = STRBUF_INIT; Hrm. I thought at first that

Re: [PATCH v3 05/10] abspath: convert real_path_internal() to strbuf

2014-07-28 Thread Jeff King
On Mon, Jul 28, 2014 at 08:28:30PM +0200, René Scharfe wrote: @@ -60,26 +58,22 @@ static const char *real_path_internal(const char *path, int die_on_error) goto error_out; } - if (strlcpy(buf, path, PATH_MAX) = PATH_MAX) { - if (die_on_error)

Re: [PATCH v3 05/10] abspath: convert real_path_internal() to strbuf

2014-07-28 Thread Junio C Hamano
Jeff King p...@peff.net writes: On Mon, Jul 28, 2014 at 08:28:30PM +0200, René Scharfe wrote: @@ -60,26 +58,22 @@ static const char *real_path_internal(const char *path, int die_on_error) goto error_out; } -if (strlcpy(buf, path, PATH_MAX) = PATH_MAX) { -

Re: [PATCH v3 05/10] abspath: convert real_path_internal() to strbuf

2014-07-28 Thread René Scharfe
Am 28.07.2014 um 21:09 schrieb Jeff King: On Mon, Jul 28, 2014 at 08:28:30PM +0200, René Scharfe wrote: static const char *real_path_internal(const char *path, int die_on_error) { - static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1]; + static struct strbuf

Re: [PATCH v3 05/10] abspath: convert real_path_internal() to strbuf

2014-07-28 Thread René Scharfe
Am 28.07.2014 um 23:42 schrieb Junio C Hamano: Jeff King p...@peff.net writes: On Mon, Jul 28, 2014 at 08:28:30PM +0200, René Scharfe wrote: @@ -60,26 +58,22 @@ static const char *real_path_internal(const char *path, int die_on_error) goto error_out; } -