From d9f38a7052c22c7762aa5b98b401e8a324336bce Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 12 Apr 2024 17:39:21 -0400 Subject: [PATCH] PR31637: debuginfod-find -v SIGSEGV Correct an off-by-one error in argv parsing. Reported-By: Signed-Off-By: Frank Ch. Eigler --- debuginfod/debuginfod-find.c | 2 +- tests/run-debuginfod-section.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/debuginfod/debuginfod-find.c b/debuginfod/debuginfod-find.c index 307310988..080dd8f2c 100644 --- a/debuginfod/debuginfod-find.c +++ b/debuginfod/debuginfod-find.c @@ -136,7 +136,7 @@ main(int argc, char** argv) int remaining; (void) argp_parse (&argp, argc, argv, ARGP_IN_ORDER|ARGP_NO_ARGS, &remaining, NULL); - if (argc < 2 || remaining+1 == argc) /* no arguments or at least two non-option words */ + if (argc < 2 || remaining+1 >= argc) /* no arguments or at least two non-option words */ { argp_help (&argp, stderr, ARGP_HELP_USAGE, argv[0]); return 1; diff --git a/tests/run-debuginfod-section.sh b/tests/run-debuginfod-section.sh index 66e53e832..6ac596887 100755 --- a/tests/run-debuginfod-section.sh +++ b/tests/run-debuginfod-section.sh @@ -81,6 +81,9 @@ wait_ready $PORT1 'thread_busy{role="scan"}' 0 # Build-id for a file in the one of the testsuite's F31 rpms RPM_BUILDID=d44d42cbd7d915bc938c81333a21e355a6022fb7 +# PR31637 argc range checking +(testrun ${abs_top_builddir}/debuginfod/debuginfod-find -v 2>&1 || true) | grep Usage: + # Download sections from files indexed with -F testrun ${abs_top_builddir}/debuginfod/debuginfod-find -vvv section $BUILDID .debug_info testrun ${abs_top_builddir}/debuginfod/debuginfod-find -vvv section $BUILDID .text -- 2.47.2