diff options
author | Frank Ch. Eigler <fche@redhat.com> | 2024-04-12 17:39:21 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@redhat.com> | 2024-04-12 17:39:21 -0400 |
commit | d9f38a7052c22c7762aa5b98b401e8a324336bce (patch) | |
tree | 8d702e0f17d8e97d2c431bfdf2e8612444187b7d | |
parent | d4b0848be5f575ff9464fee12ce7be416e4fb392 (diff) | |
download | elfutils-d9f38a7052c22c7762aa5b98b401e8a324336bce.tar.gz |
PR31637: debuginfod-find -v SIGSEGV
Correct an off-by-one error in argv parsing.
Reported-By: <nolange79@gmail.com>
Signed-Off-By: Frank Ch. Eigler <fche@redhat.com>
-rw-r--r-- | debuginfod/debuginfod-find.c | 2 | ||||
-rwxr-xr-x | tests/run-debuginfod-section.sh | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/debuginfod/debuginfod-find.c b/debuginfod/debuginfod-find.c index 30731098..080dd8f2 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 66e53e83..6ac59688 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 |