[PATCH 1/6] revision: use strtol_i() for exclude_parent
- From
René Scharfe <l.s.r@web.de>
- Date
- Sep 15, 2022, 14:51 UTC
- Message-ID
- <9baebb3d-8f2a-33eb-3f42-3e1755883d19@web.de>
- In-Reply-To
- <ba6eea28-fb3a-b376-2529-351727c02f1a@web.de>
Avoid silent overflow of the int exclude_parent by using the appropriate function, strtol_i(), to parse its value.
Signed-off-by: René Scharfe <l.s.r@web.de> --- revision.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/revision.c b/revision.c index d5f4463cb6..0b8d48f94c 100644 --- a/revision.c +++ b/revision.c @@ -2119,9 +2119,8 @@ static int handle_revision_arg_1(const char *arg_, struct rev_info *revs, int fl int exclude_parent = 1; if (mark[2]) { - char *end; - exclude_parent = strtoul(mark + 2, &end, 10); - if (*end != '\0' || !exclude_parent) + if (strtol_i(mark + 2, 10, &exclude_parent) || + exclude_parent < 1) return -1; } -- 2.37.3