debuginfod-find: Correct error check for -v source combo
authorFrank Ch. Eigler <fche@redhat.com>
Tue, 24 Mar 2020 19:01:58 +0000 (15:01 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Tue, 24 Mar 2020 19:01:58 +0000 (15:01 -0400)
Hardcoding argv[2] is wrong in presence of -v option.  Code
immediately following did the correct argv[] indexing already.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
debuginfod/ChangeLog
debuginfod/debuginfod-find.c

index 2410430..00e7ec6 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-24  Frank Ch. Eigler  <fche@redhat.com>
+
+       * debuginfod-find.c (main): Correct /source full-pathness check for
+       "debuginfod-find -v source deadbeef /pathname" case.
+
 2020-03-22  Frank Ch. Eigler  <fche@redhat.com>
 
        * debuginfod-client.c (struct debuginfod_client): Add url field.
index 787779c..400c268 100644 (file)
@@ -1,6 +1,6 @@
 /* Command-line frontend for retrieving ELF / DWARF / source files
    from the debuginfod.
-   Copyright (C) 2019 Red Hat, Inc.
+   Copyright (C) 2019-2020 Red Hat, Inc.
    This file is part of elfutils.
 
    This file is free software; you can redistribute it and/or modify
@@ -121,7 +121,7 @@ main(int argc, char** argv)
                                    &cache_name);
   else if (strcmp(argv[remaining], "source") == 0)
     {
-      if (remaining+2 == argc || argv[3][0] != '/')
+      if (remaining+2 == argc || argv[remaining+2][0] != '/')
         {
           fprintf(stderr, "If FILETYPE is \"source\" then absolute /FILENAME must be given\n");
           return 1;