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

Re: [PATCH v8] format-patch: allow a non-integral version numbers

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 21, 2021, 05:45 UTC
Message-ID
<xmqqpmztcb6r.fsf@gitster.g>
In-Reply-To
<CAPig+cQBATCe4XFt1k0_EfYvb61_RVgTO0NGy6Ykg7frNPbtpQ@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 16 quoted lines
> This new example raises the question about what happens if the
> argument to --reroll-count contains characters which don't belong in
> pathnames. For instance, what happens if `--reroll-count=1/2` is
> specified? Most likely, it will fail trying to write the
> "v1/2-whatever.patch" file to a nonexistent directory named "v1".
>
>> diff --git a/log-tree.c b/log-tree.c
>> @@ -369,8 +369,8 @@ void fmt_output_subject(struct strbuf *filename,
>> +       if (info->reroll_count)
>> +               strbuf_addf(filename, "v%s-", info->reroll_count);
>>         strbuf_addf(filename, "%04d-%s", nr, subject);
>
> To protect against that problem, you may need to call
> format_sanitized_subject() manually after formatting "v%s-". (I'm just
> looking at this code for the first time, so I could be hopelessly
> wrong. There may be a better way to fix it.)

This kind of discovery of what I and others missed is why I love to see reviews on this list ;-)

Yes, slash is of course very problematic, but what we've been doing to the patch filenames was to ensure that they will be free of $IFS whitespaces and shell glob special characters as well, and we should treat the "reroll count" just like the other end-user controlled input, i.e. the title of the patch, and sanitize it the same way.

So I am pretty sure format_sanitized_subject() is the right way to go.

Previous: Eric SunshineNext: Eric Sunshine
Message 38 of 49 in “format-patch: allow a non-integral version numbers”
  1. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Feb 25, 2021
  2. Eric SunshineFeb 25, 2021
  3. ZheNing HuFeb 27, 2021
  4. Junio C HamanoFeb 25, 2021
  5. ZheNing HuFeb 27, 2021
  6. Đoàn Trần Công DanhMar 17, 2021
  7. Junio C HamanoMar 17, 2021
  8. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 1, 2021
  9. Junio C HamanoMar 3, 2021
  10. Denton LiuMar 3, 2021
  11. Junio C HamanoMar 4, 2021
  12. ZheNing HuMar 4, 2021
  13. Eric SunshineMar 4, 2021
  14. Denton LiuMar 4, 2021
  15. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 4, 2021
  16. Denton LiuMar 4, 2021
  17. ZheNing HuMar 5, 2021
  18. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 5, 2021
  19. Eric SunshineMar 15, 2021
  20. ZheNing HuMar 16, 2021
  21. Eric SunshineMar 16, 2021
  22. Junio C HamanoMar 17, 2021
  23. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 16, 2021
  24. Eric SunshineMar 16, 2021
  25. ZheNing HuMar 17, 2021
  26. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 18, 2021
  27. Eric SunshineMar 19, 2021
  28. ZheNing HuMar 19, 2021
  29. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 19, 2021
  30. Junio C HamanoMar 19, 2021
  31. ZheNing HuMar 20, 2021
  32. Junio C HamanoMar 19, 2021
  33. ZheNing HuMar 20, 2021
  34. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 20, 2021
  35. Junio C HamanoMar 20, 2021
  36. ZheNing HuMar 21, 2021
  37. Eric SunshineMar 21, 2021
  38. Junio C HamanoMar 21, 2021
  39. Eric SunshineMar 21, 2021
  40. Denton LiuMar 24, 2021
  41. ZheNing HuMar 21, 2021
  42. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 21, 2021
  43. Eric SunshineMar 23, 2021
  44. Junio C HamanoMar 23, 2021
  45. ZheNing HuMar 23, 2021
  46. ZheNing HuMar 23, 2021
  47. format-patch: allow a non-integral version numbersZheNing Hu via GitGitGadget, Mar 23, 2021
  48. Eric SunshineMar 24, 2021
  49. ZheNing HuMar 24, 2021

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.