Message ID | 9baebb3d-8f2a-33eb-3f42-3e1755883d19@web.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | revision: fix order of revs for ^! | expand |
On Thu, Sep 15, 2022 at 7:51 AM René Scharfe <l.s.r@web.de> wrote: > 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> Nice (albeit small) improvement regardless of anything else, Chris
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; }
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(-) -- 2.37.3