Re: [PATCH] rev-parse: fix --resolve-git-dir argument handling
On Tue, Feb 18, 2014 at 04:25:37PM -0800, Junio C Hamano wrote: Junio C Hamano gits...@pobox.com writes: John Keeping j...@keeping.me.uk writes: There are two problems here: 1) If no argument is provided, then the command segfaults 2) The argument is not consumed, so there will be excess output Fix both of these in one go by restructuring the handler for this option. Reported-by: Daniel Hahler genml+git-2...@thequod.de Signed-off-by: John Keeping j...@keeping.me.uk --- Looks sensible; thanks. Ehh, I spoke too fast. Don't we already have this queued as a43219f2 (rev-parse: check i before using argv[i] against argc, 2014-01-28)? Yes, and it catches more cases than mine. I only checked against master and had missed that when it went past on the list. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] rev-parse: fix --resolve-git-dir argument handling
John Keeping j...@keeping.me.uk writes: There are two problems here: 1) If no argument is provided, then the command segfaults 2) The argument is not consumed, so there will be excess output Fix both of these in one go by restructuring the handler for this option. Reported-by: Daniel Hahler genml+git-2...@thequod.de Signed-off-by: John Keeping j...@keeping.me.uk --- Looks sensible; thanks. builtin/rev-parse.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index aaeb611..645cc4a 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -738,9 +738,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) continue; } if (!strcmp(arg, --resolve-git-dir)) { - const char *gitdir = resolve_gitdir(argv[i+1]); + const char *gitdir; + if (++i = argc) + die(--resolve-git-dir requires an argument); + gitdir = resolve_gitdir(argv[i]); if (!gitdir) - die(not a gitdir '%s', argv[i+1]); + die(not a gitdir '%s', argv[i]); puts(gitdir); continue; } -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] rev-parse: fix --resolve-git-dir argument handling
Junio C Hamano gits...@pobox.com writes: John Keeping j...@keeping.me.uk writes: There are two problems here: 1) If no argument is provided, then the command segfaults 2) The argument is not consumed, so there will be excess output Fix both of these in one go by restructuring the handler for this option. Reported-by: Daniel Hahler genml+git-2...@thequod.de Signed-off-by: John Keeping j...@keeping.me.uk --- Looks sensible; thanks. Ehh, I spoke too fast. Don't we already have this queued as a43219f2 (rev-parse: check i before using argv[i] against argc, 2014-01-28)? -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html