public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Maks Mishin <maks.mishinfz@gmail.com>
To: elfutils-devel@sourceware.org
Cc: Maks Mishin <maks.mishinFZ@gmail.com>
Subject: [PATCH] nm: Fix descriptor leak
Date: Thu, 28 Mar 2024 23:49:58 +0300	[thread overview]
Message-ID: <20240328204958.9657-1-maks.mishinFZ@gmail.com> (raw)

The descriptor 'dwfl_fd' is created at nm.c:1278 by calling
function 'dup' and lost at nm.c:1593.

Found by RASU JSC.

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
 src/nm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/nm.c b/src/nm.c
index 3675f59b..fee397dd 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -1521,6 +1521,8 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr,
     }
   if (dwfl != NULL)
     dwfl_end (dwfl);
+  if (dwfl_fd != NULL)
+    close(dwfl_fd);
 }
 
 
-- 
2.30.2


             reply	other threads:[~2024-03-28 20:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 20:49 Maks Mishin [this message]
2024-03-28 21:12 ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240328204958.9657-1-maks.mishinFZ@gmail.com \
    --to=maks.mishinfz@gmail.com \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).