]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revision: use strtol_i() for exclude_parent
authorRené Scharfe <l.s.r@web.de>
Sat, 1 Oct 2022 10:25:36 +0000 (12:25 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 1 Oct 2022 22:58:33 +0000 (15:58 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c

index 0c6e26cd9c8ff8d4f6fdb6050d7df57be460256e..da9dfd405e8bfed8651dc599195ed7345f401609 100644 (file)
@@ -2112,9 +2112,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;
                }