Versioned shared libraries typically have several symlinks pointing
to them directly and indirectly. When %_build_id_links is set to compat or
separate this causes bogus warnings about duplicate build-ids.

It looks commit bbfe1f86b2e4b5c0bd499d9f3dd9de9c9c20fff2 intends to skip
symlinks since it filters on S_ISREG(), but since uses fstat()
on already open()'ed file it ends up stat()'ing the symlink target.
Flip stat() + open() around and use lstat() instead to fix it.
---
 build/files.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/build/files.c b/build/files.c
index f297622..0504f47 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1671,11 +1671,10 @@ static int generateBuildIDs(FileList fl)
     int needMain = 0;
     int needDbg = 0;
     for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) {
-       int fd;
-       fd = open (flp->diskPath, O_RDONLY);
-       if (fd >= 0) {
-           struct stat sbuf;
-           if (fstat (fd, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
+       struct stat sbuf;
+       if (lstat(flp->diskPath, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
+           int fd = open (flp->diskPath, O_RDONLY);
+           if (fd >= 0) {
                Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
                if (elf != NULL && elf_kind(elf) == ELF_K_ELF) {
                    const void *build_id;
@@ -1741,8 +1740,8 @@ static int generateBuildIDs(FileList fl)
                    }
                    elf_end (elf);
                }
+               close (fd);
            }
-           close (fd);
        }
     }
 
-- 
2.9.3

_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to