[edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in rename()
Jayaprakash, N
n.jayaprakash at intel.com
Tue Aug 22 03:21:54 UTC 2023
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 at bsdio.com>
Cc: Michael D Kinney <michael.d.kinney at intel.com>
Cc: Jayaprakash N <n.jayaprakash at intel.com>
Signed-off-by: Kloper Dimitry <dimitry.kloper at 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/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list