]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
PR31637: debuginfod-find -v SIGSEGV
authorFrank Ch. Eigler <fche@redhat.com>
Fri, 12 Apr 2024 21:39:21 +0000 (17:39 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Fri, 12 Apr 2024 21:39:21 +0000 (17:39 -0400)
Correct an off-by-one error in argv parsing.

Reported-By: <nolange79@gmail.com>
Signed-Off-By: Frank Ch. Eigler <fche@redhat.com>
debuginfod/debuginfod-find.c
tests/run-debuginfod-section.sh

index 307310988c4c0b725d94a57cbd552cb122c490bf..080dd8f2c6a35f491b916de358a10198f83fab6b 100644 (file)
@@ -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;
index 66e53e8328731b4f553d5dc20aef85a4b607bbc8..6ac5968872e33404ac4d317c96cd19b589de830d 100755 (executable)
@@ -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