git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] rev-parse: Check argc before using argv[i+1]

From
DSDavid Sharp <dhsharp@google.com>
Date
Jan 28, 2014, 22:03 UTC
Message-ID
<CAJL_ekvepmKn6OmLYZWO==RMAbkkArAOLK1iASQG58ShKXU_4g@mail.gmail.com>
In-Reply-To
<52E828AD.2040609@kdbg.org>
On Tue, Jan 28, 2014 at 2:01 PM, Johannes Sixt <j6t@kdbg.org> wrote:
Show 19 quoted lines
> Am 28.01.2014 22:21, schrieb David Sharp:
>> @@ -738,9 +740,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 = argv[++i];
>>                               if (!gitdir)
>> -                                     die("not a gitdir '%s'", argv[i+1]);
>> +                                     die("--resolve-git-dir requires an argument");
>> +                             gitdir = resolve_gitdir(gitdir);
>> +                             if (!gitdir)
>> +                                     die("not a gitdir '%s'", argv[i]);
>>                               puts(gitdir);
>>                               continue;
>>                       }
>
> In this hunk, I don't see where the old code incremented i for the
> argument. Was this another bug lurking that is fixed now?
Yup. I did notice that too. Should have mentioned it in the description.
>
> -- Hannes
>
Previous: Johannes Sixt
Message 8 of 8 in “rev-parse: Check argc before using argv[i+1]”
  1. rev-parse: Check argc before using argv[i+1]David Sharp, Jan 27, 2014
  2. Junio C HamanoJan 28, 2014
  3. David SharpJan 28, 2014
  4. rev-parse: Check argc before using argv[i+1]David Sharp, Jan 28, 2014
  5. Junio C HamanoJan 28, 2014
  6. David SharpJan 28, 2014
  7. Johannes SixtJan 28, 2014
  8. David SharpJan 28, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.