Reviewed-by: Michael D Kinney <michael.d.kinn...@intel.com>
> -----Original Message----- > From: Jayaprakash, N <n.jayaprak...@intel.com> > Sent: Monday, August 21, 2023 8:22 PM > To: devel@edk2.groups.io > Cc: Jayaprakash, N <n.jayaprak...@intel.com>; Rebecca Cran > <rebe...@bsdio.com>; Kinney, Michael D <michael.d.kin...@intel.com>; > Kloper, Dimitry <dimitry.klo...@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 <rebe...@bsdio.com> > Cc: Michael D Kinney <michael.d.kin...@intel.com> > Cc: Jayaprakash N <n.jayaprak...@intel.com> > Signed-off-by: Kloper Dimitry <dimitry.klo...@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/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-