From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH] sequencer.c: fix overflow & segfault in parse_strategy_opts()
Date: Tue, 07 Mar 2023 15:23:25 -0800 [thread overview]
Message-ID: <xmqqttywuowi.fsf@gitster.g> (raw)
In-Reply-To: <xmqq5ybcxs1r.fsf@gitster.g> (Junio C. Hamano's message of "Tue, 07 Mar 2023 11:47:12 -0800")
Junio C Hamano <gitster@pobox.com> writes:
> This made me look at split_cmdline_strerror(). It is a table lookup
> into split_cmdline_errors[] in alias.c which looks like this:
>
> static const char *split_cmdline_errors[] = {
> N_("cmdline ends with \\"),
> N_("unclosed quote"),
> N_("too many arguments"),
> };
>
> So the result is properly localized, but I suspect that the string
> after : should not be enclosed within a pair of single quotes.
>
> die(_("could not split '%s': %s", strategy_opts_string,
> split_cmdline_strerror(count)));
>
> Other than that, nice find.
I'll queue this on top.
----- >8 ---------- >8 ---------- >8 ---------- >8 -----
Subject: [PATCH] SQUASH: no point in quoting strerror like messages
The error message is taken from a limited and fixed set of strings
and we do not usually enclose strerror(errno) inside a pair of
single quotes.
---
sequencer.c | 2 +-
t/t3436-rebase-more-options.sh | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index cc59a1c491..e4a3f0081f 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2885,7 +2885,7 @@ void parse_strategy_opts(struct replay_opts *opts, char *raw_opts)
count = split_cmdline(strategy_opts_string,
(const char ***)&opts->xopts);
if (count < 0)
- die(_("could not split '%s': '%s'"), strategy_opts_string,
+ die(_("could not split '%s': %s"), strategy_opts_string,
split_cmdline_strerror(count));
opts->xopts_nr = count;
for (i = 0; i < opts->xopts_nr; i++) {
diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh
index 195ace3455..c3184c9ade 100755
--- a/t/t3436-rebase-more-options.sh
+++ b/t/t3436-rebase-more-options.sh
@@ -42,7 +42,7 @@ test_expect_success 'setup' '
test_expect_success 'bad -X <strategy-option> arguments: unclosed quote' '
cat >expect <<-\EOF &&
- fatal: could not split '\''--bad'\'': '\''unclosed quote'\''
+ fatal: could not split '\''--bad'\'': unclosed quote
EOF
test_expect_code 128 git rebase -X"bad argument\"" side main >out 2>actual &&
test_must_be_empty out &&
@@ -51,7 +51,7 @@ test_expect_success 'bad -X <strategy-option> arguments: unclosed quote' '
test_expect_success 'bad -X <strategy-option> arguments: bad escape' '
cat >expect <<-\EOF &&
- fatal: could not split '\''--bad'\'': '\''cmdline ends with \'\''
+ fatal: could not split '\''--bad'\'': cmdline ends with \
EOF
test_expect_code 128 git rebase -X"bad escape \\" side main >out 2>actual &&
test_must_be_empty out &&
--
2.40.0-rc2
next prev parent reply other threads:[~2023-03-07 23:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 18:21 [PATCH] sequencer.c: fix overflow & segfault in parse_strategy_opts() Ævar Arnfjörð Bjarmason
2023-03-07 19:47 ` Junio C Hamano
2023-03-07 23:23 ` Junio C Hamano [this message]
2023-03-08 16:20 ` Phillip Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqttywuowi.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).