aboutsummaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-03-27 11:00:02 -0700
committerJunio C Hamano <gitster@pobox.com>2026-03-27 11:00:02 -0700
commitcb77c3a6a7f508776c5bdd874ee650ceb28dc1ba (patch)
tree93dc52ba10193b8e8809271aa2d2b5b10bee928f /apply.c
parentf23054409b4050900a56bd69467a60866a525d5c (diff)
parentd05d84c5f507e8b973982e9cf3a27a07cd94fcb8 (diff)
downloadgit-cb77c3a6a7f508776c5bdd874ee650ceb28dc1ba.tar.xz
Merge branch 'mf/apply-p-no-atoi'
"git apply -p<n>" parses <n> more carefully now. * mf/apply-p-no-atoi: apply.c: fix -p argument parsing
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/apply.c b/apply.c
index b6dd1066a0..52cd590bdb 100644
--- a/apply.c
+++ b/apply.c
@@ -4981,7 +4981,8 @@ static int apply_option_parse_p(const struct option *opt,
BUG_ON_OPT_NEG(unset);
- state->p_value = atoi(arg);
+ if (strtol_i(arg, 10, &state->p_value) < 0 || state->p_value < 0)
+ die(_("option -p expects a non-negative integer, got '%s'"), arg);
state->p_value_known = 1;
return 0;
}