Thread (12 messages) 12 messages, 2 authors, 2022-10-01
STALE1382d

[PATCH 1/6] revision: use strtol_i() for exclude_parent

From: René Scharfe <hidden>
Date: 2022-09-15 14:51:14
Subsystem: the rest · Maintainer: Linus Torvalds

Avoid silent overflow of the int exclude_parent by using the appropriate
function, strtol_i(), to parse its value.

Signed-off-by: René Scharfe <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help