From: "Jayaprakash, N" <n.jayaprakash@intel.com>
To: devel@edk2.groups.io
Cc: Jayaprakash N <n.jayaprakash@intel.com>,
Rebecca Cran <rebecca@bsdio.com>,
Michael D Kinney <michael.d.kinney@intel.com>,
Kloper Dimitry <dimitry.kloper@intel.com>
Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in rename()
Date: Tue, 22 Aug 2023 08:51:54 +0530 [thread overview]
Message-ID: <20230822032154.2009-2-n.jayaprakash@intel.com> (raw)
In-Reply-To: <20230822032154.2009-1-n.jayaprakash@intel.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4529
rename() call leads to a function that makes open() for source file
to be renamed. The resulting file descriptor is never closed.
If you have to rename a couple of files this will quickly exhaust
the descriptor table.
The fix is trivial - just close the fd before returning from the function.
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jayaprakash N <n.jayaprakash@intel.com>
Signed-off-by: Kloper Dimitry <dimitry.kloper@intel.com>
---
StdLib/LibC/Uefi/Devices/UefiShell/daShell.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c b/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c
index 861765e..06fcc3b 100644
--- a/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c
+++ b/StdLib/LibC/Uefi/Devices/UefiShell/daShell.c
@@ -670,6 +670,7 @@ da_ShellRename(
free(NewFileInfo);
if(Status == EFI_SUCCESS) {
// File has been successfully renamed. We are DONE!
+ close(OldFd);
return 0;
}
errno = EFI2errno( Status );
@@ -688,6 +689,7 @@ da_ShellRename(
else {
errno = ENOMEM;
}
+ close(OldFd);
}
return -1;
}
--
2.40.0.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107942): https://edk2.groups.io/g/devel/message/107942
Mute This Topic: https://groups.io/mt/100888179/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-08-22 3:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 3:21 [edk2-devel] [edk2-libc Patch 0/1] file descriptor leak in rename Jayaprakash, N
2023-08-22 3:21 ` Jayaprakash, N [this message]
2023-08-22 17:46 ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in rename() Michael D Kinney
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-list 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=20230822032154.2009-2-n.jayaprakash@intel.com \
--to=devel@edk2.groups.io \
/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