Thread View: linux.kernel.git
3 messages
3 total messages
Started by Kaartic Sivaraam
Tue, 17 Nov 2026 16:03
[PATCH] fast-import: do not show the path when "feature export-marks" is forbidden
Author: Kaartic Sivaraam
Date: Tue, 17 Nov 2026 16:03
Date: Tue, 17 Nov 2026 16:03
54 lines
12984 bytes
12984 bytes
Since 68061e3470 (fast-import: disallow "feature export-marks" by
default, 2019-08-29), a stream that uses "feature export-marks=<path>"
without --allow-unsafe-features dies with
feature 'export-marks=<path>' forbidden in input without --allow-unsafe-features
because the whole feature string, including the "=<path>" argument,
is passed to check_unsafe_feature(). The import-marks variants pass
just the feature name, so their messages do not include the path.
Pass "export-marks" to match, and make the existing test check the
message, not just that the command fails.
Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
---
While backporting patches for a security release, I noticed this.
Was waiting for the security fix to go out before sending it.
---
builtin/fast-import.c | 2 +-
t/t9300-fast-import.sh | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index ab5d2a2344..998167794c 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -3918,7 +3918,7 @@ static int parse_one_feature(struct fast_import_state *state,
check_unsafe_feature(state, "import-marks-if-exists");
option_import_marks(state, arg, 1, 1);
} else if (skip_prefix(feature, "export-marks=", &arg)) {
- check_unsafe_feature(state, feature);
+ check_unsafe_feature(state, "export-marks");
option_export_marks(state, arg);
} else if (!strcmp(feature, "alias")) {
; /* Don't die - this feature is supported */
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 15f511fb6b..33c04e0315 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -2337,7 +2337,8 @@ test_expect_success 'R: only one import-marks feature allowed per stream' '
test_expect_success 'R: export-marks feature forbidden by default' '
echo "feature export-marks=git.marks" >input &&
- test_must_fail git fast-import <input
+ test_must_fail git fast-import <input 2>err &&
+ test_grep "feature .export-marks. forbidden" err
'
test_expect_success 'R: export-marks feature results in a marks file being created' '
---
base-commit: e1ec09b23c8e0deb21a0b95ac5996422277395d4
change-id: 20261104-ks-fast-import-consistent-check-unsafe-0a94ffda7518
Re: [PATCH] fast-import: do not show the path when "feature export-marks" is forbidden
Author: Karthik Nayak
Date: Wed, 18 Nov 2026 11:21
Date: Wed, 18 Nov 2026 11:21
95 lines
15937 bytes
15937 bytes
--000000000000d9179506608b35d1
Content-Type: text/plain; charset="UTF-8"
Kaartic Sivaraam <kaartic.sivaraam@gmail.com> writes:
> Since 68061e3470 (fast-import: disallow "feature export-marks" by
> default, 2019-08-29), a stream that uses "feature export-marks=<path>"
> without --allow-unsafe-features dies with
>
> feature 'export-marks=<path>' forbidden in input without --allow-unsafe-features
>
> because the whole feature string, including the "=<path>" argument,
> is passed to check_unsafe_feature(). The import-marks variants pass
> just the feature name, so their messages do not include the path.
>
> Pass "export-marks" to match, and make the existing test check the
> message, not just that the command fails.
>
It's not just 'import-marks', but all other features provide a static
string. So makes sense.
> Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
> ---
> While backporting patches for a security release, I noticed this.
> Was waiting for the security fix to go out before sending it.
> ---
> builtin/fast-import.c | 2 +-
> t/t9300-fast-import.sh | 3 ++-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/fast-import.c b/builtin/fast-import.c
> index ab5d2a2344..998167794c 100644
> --- a/builtin/fast-import.c
> +++ b/builtin/fast-import.c
> @@ -3918,7 +3918,7 @@ static int parse_one_feature(struct fast_import_state *state,
> check_unsafe_feature(state, "import-marks-if-exists");
> option_import_marks(state, arg, 1, 1);
> } else if (skip_prefix(feature, "export-marks=", &arg)) {
> - check_unsafe_feature(state, feature);
> + check_unsafe_feature(state, "export-marks");
Change looks sensible!
> option_export_marks(state, arg);
> } else if (!strcmp(feature, "alias")) {
> ; /* Don't die - this feature is supported */
> diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
> index 15f511fb6b..33c04e0315 100755
> --- a/t/t9300-fast-import.sh
> +++ b/t/t9300-fast-import.sh
> @@ -2337,7 +2337,8 @@ test_expect_success 'R: only one import-marks feature allowed per stream' '
>
> test_expect_success 'R: export-marks feature forbidden by default' '
> echo "feature export-marks=git.marks" >input &&
> - test_must_fail git fast-import <input
> + test_must_fail git fast-import <input 2>err &&
> + test_grep "feature .export-marks. forbidden" err
> '
>
Sigh, this will conflict with my long series [1]. So one of us will have
to merge the other topic in and send in a new version. Let's see how
things go :)
> test_expect_success 'R: export-marks feature results in a marks file being created' '
>
> ---
> base-commit: e1ec09b23c8e0deb21a0b95ac5996422277395d4
> change-id: 20261104-ks-fast-import-consistent-check-unsafe-0a94ffda7518
[1]: https://lore.kernel.org/git/20261112-kn-fast-import-tests-1-v2-0-b8c3a0ab27e8@gmail.com/
--000000000000d9179506608b35d1
Content-Type: application/pgp-signature; name="signature.asc"
Content-Disposition: attachment; filename="signature.asc"
Content-Transfer-Encoding: base64
X-Attachment-Id: 40fb8d4fd0a1c191_0.1
LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSEtCQUVCQ2dBMEZpRUVWODVNZjJOMWNR
L0xaY1lHUHRXZkpJNUdqSDhGQW1yOWlpZ1dIR3RoY25Sb2FXc3UKTVRnNFFHZHRZV2xzTG1OdmJR
QUtDUkErMVo4a2prYU1mN0JtQy85a0hNRENLTmdqOWNKVis2TGVFYzRGT2lFcwpIWXpmbUZ3ejYy
M01FbXp5YVdxUHRSR1Y2T0thZ2VMWFVzL0h5Z2Z3SlVHakZHM2RsU3ZFN0pzZXhsemluUU9FCmpP
UDVkV0F0YlAvUU5sVkxGbS9xVU1FNHFqWktMUVZsV2pyb0RzTWJtTTZrbVJpRURrZUplRUw0YXhE
UzNQQjUKdFJ3alg5b3NzYkFYL2c0alR3MFBBaUh0Smx0c0RvbXFLaEJqSUZ6aVNJd1NBRGkzWCtW
ZFdHTDhNb3NPVTJmSQpxemtQRy8vRlNYWjdJWmpDWUlsb0tWMjVvZGRPbmswb1BRdTRLUTJaQnd5
dzJ1alRqMXNRcUlxWlovUE1LMjBLClBOMitwL1c5ckxhTnZBRXBLSWVHVHd6ZzFQWkxWczgxTis4
Z1VKYjNJblQrbklQQ1lvcGZKTFY4Y1NZR3V0MkgKa0dqY3pzMHlqeDJjaFRueHcrN0xPZkdjMVBD
SXpFQmU3dVJqTGFOVUwwa3lHYUh1cjliRW1vbnZvUTZNQ21WaApiWkNGcGZiOWluek4yU2dPT2xB
Mk1zQkRqNDFCcjZ6dnNseXJ4bnpuOG1PVk40RkltbWluZy9kU3o4b3Erd0JrCmcyRWhsSHlQMkFU
MUZCL240NmRFWDlxd2luQ1lHaXFTZ3R6Vnk0ND0KPUxYWWcKLS0tLS1FTkQgUEdQIFNJR05BVFVS
RS0tLS0t
--000000000000d9179506608b35d1--
Re: [PATCH] fast-import: do not show the path when "feature export-marks" is forbidden
Author: Junio C Hamano
Date: Thu, 19 Nov 2026 18:53
Date: Thu, 19 Nov 2026 18:53
75 lines
15476 bytes
15476 bytes
Kaartic Sivaraam <kaartic.sivaraam@gmail.com> writes:
> diff --git a/builtin/fast-import.c b/builtin/fast-import.c
> index ab5d2a2344..998167794c 100644
> --- a/builtin/fast-import.c
> +++ b/builtin/fast-import.c
> @@ -3918,7 +3918,7 @@ static int parse_one_feature(struct fast_import_state *state,
> check_unsafe_feature(state, "import-marks-if-exists");
> option_import_marks(state, arg, 1, 1);
> } else if (skip_prefix(feature, "export-marks=", &arg)) {
> - check_unsafe_feature(state, feature);
> + check_unsafe_feature(state, "export-marks");
> option_export_marks(state, arg);
> } else if (!strcmp(feature, "alias")) {
> ; /* Don't die - this feature is supported */
This is an obviously correct change, but doesn't this bug caused by
forced repetition annoy anybody? This if/else if/else cascade is an
obvious trap waiting for another similar bug to be added.
Wouldn't it be much nicer if the above hunk can be rewritten like
so,
option_import_marks(state, arg, 1, 1);
- } else if (skip_prefix(feature, "export-marks=", &arg)) {
+ } else if (check_unsafe(state, feature, "export-marks", &arg)) {
- check_unsafe_feature(state, feature);
option_export_marks(state, arg);
} else if (!strcmp(feature, "alias")) {
; /* Don't die - this feature is supported */
so a separate call to check_unsafe_feature() can be lost, and we no
longer have to repeat "export-marks=" and "export-marks" for all
these "unsafe" features?
If we plan to ever add an argument-less unsafe feature, the helper
needs to be updated to require NUL (instead of '=') after we find
the end of the feature name with skip_prefix() when the feature is
an argument-less one (perhaps signaled by arg==NULL or something),
but you get the idea.
builtin/fast-import.c | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git i/builtin/fast-import.c w/builtin/fast-import.c
index ab5d2a2344..673d3f2289 100644
--- i/builtin/fast-import.c
+++ w/builtin/fast-import.c
@@ -3896,12 +3896,20 @@ static int parse_one_option(struct fast_import_state *state, const char *option)
return 1;
}
-static void check_unsafe_feature(struct fast_import_state *state,
- const char *feature)
+static int check_unsafe(struct fast_import_state *state,
+ const char *feature, const char *prefix,
+ const char **arg)
{
- if (!state->allow_unsafe_features)
- die(_("feature '%s' forbidden in input without --allow-unsafe-features"),
- feature);
+ const char *arg_;
+
+ if (skip_prefix(feature, prefix, &arg_) && *arg_ == '=') {
+ if (!state->allow_unsafe_features)
+ die(_("feature '%s' forbidden in input "
+ "without --allow-unsafe-features"), prefix);
+ *arg = arg_ + 1;
+ return 1;
+ }
+ return 0;
}
static int parse_one_feature(struct fast_import_state *state,
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads