commit:     a17419af271edc0edabe79cb6c9616fafcf15bfd
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 20 03:19:40 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Jun 20 03:19:40 2016 +0000
URL:        https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=a17419af

scanelf: avoid leaking root_fd when multiple --root args are passed

 scanelf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scanelf.c b/scanelf.c
index 42fe4c5..3f33d89 100644
--- a/scanelf.c
+++ b/scanelf.c
@@ -2350,6 +2350,8 @@ static int parseargs(int argc, char *argv[])
                case 'I': show_osabi = 1; break;
                case 'Y': show_eabi = 1; break;
                case 128:
+                       if (root_fd != AT_FDCWD)
+                               close(root_fd);
                        root_fd = open(optarg, O_RDONLY|O_CLOEXEC);
                        if (root_fd == -1)
                                err("Could not open root: %s", optarg);

Reply via email to