The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3ede04c78c7c726ed79a39d22c65a58d0ecc5d00

commit 3ede04c78c7c726ed79a39d22c65a58d0ecc5d00
Author:     Konstantin Belousov <k...@freebsd.org>
AuthorDate: 2021-11-19 04:07:58 +0000
Commit:     Konstantin Belousov <k...@freebsd.org>
CommitDate: 2021-11-24 23:55:04 +0000

    ldconfig(8): check for no-args command line after options are parsed
    
    Default action for ldconfig is specified as -R AKA 'append', and for
    no-args (without options changing default actions), ldconfig should
    append empty list of directories to current list.  But because the check
    was done before options were parsed out, presence of any option turned
    off default rescan.
    
    As result, innocently-looked commands like `ldconfig -v' were interpreted
    as setting directory hints list to one specified on the command line,
    i.e. empty.
    
    Reported by:    https://github.com/mesonbuild/meson/issues/9592
    Reviewed by:    emaste
    Tested by:      jbeich
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D33058
---
 sbin/ldconfig/ldconfig.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sbin/ldconfig/ldconfig.c b/sbin/ldconfig/ldconfig.c
index 288c22813121..b039412a648b 100644
--- a/sbin/ldconfig/ldconfig.c
+++ b/sbin/ldconfig/ldconfig.c
@@ -90,9 +90,7 @@ main(int argc, char **argv)
                hints_file = _PATH_ELF32_HINTS;
        else
                hints_file = _PATH_ELF_HINTS;
-       if (argc == 1)
-               rescan = true;
-       else while((c = getopt(argc, argv, "Rf:imrsv")) != -1) {
+       while((c = getopt(argc, argv, "Rf:imrsv")) != -1) {
                switch (c) {
                case 'R':
                        rescan = true;
@@ -121,11 +119,14 @@ main(int argc, char **argv)
                }
        }
 
-       if (justread)
+       if (justread) {
                list_elf_hints(hints_file);
-       else
+       } else {
+               if (argc == optind)
+                       rescan = true;
                update_elf_hints(hints_file, argc - optind,
                    argv + optind, merge || rescan);
+       }
        exit(0);
 }
 

Reply via email to