[edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in rename()
Michael D Kinney
michael.d.kinney at intel.com
Tue Aug 22 17:46:02 UTC 2023
Reviewed-by: Michael D Kinney <michael.d.kinneyu at intel.com>
> -----Original Message-----
> From: Jayaprakash, N <n.jayaprakash at intel.com>
> Sent: Monday, August 21, 2023 8:22 PM
> To: devel at edk2.groups.io
> Cc: Jayaprakash, N <n.jayaprakash at intel.com>; Rebecca Cran
> <rebecca at bsdio.com>; Kinney, Michael D <michael.d.kinney at intel.com>;
> Kloper, Dimitry <dimitry.kloper at intel.com>
> Subject: [edk2-libc Patch 1/1] edk2-libc/StdLib: file descriptor leak in
> rename()
>
> 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 (#107955): https://edk2.groups.io/g/devel/message/107955
Mute This Topic: https://groups.io/mt/100888179/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3943202/1813853/130120423/xyzzy [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list