[edk2-devel] [edk2-libc Patch] StdLib/LibC/Uefi/Devices/Utility: Fix use after free

Michael D Kinney posted 1 patch 2 years, 8 months ago
Failed in applying to current master (apply log)
StdLib/LibC/Uefi/Devices/Utility/Path.c | 1 +
1 file changed, 1 insertion(+)
[edk2-devel] [edk2-libc Patch] StdLib/LibC/Uefi/Devices/Utility: Fix use after free
Posted by Michael D Kinney 2 years, 8 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=38

Set MPath to NULL after free(MPath) to guarantee that MPath
is not used after the free() call.

Cc: Rebecca Cran <rebecca@nuviainc.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 StdLib/LibC/Uefi/Devices/Utility/Path.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/StdLib/LibC/Uefi/Devices/Utility/Path.c b/StdLib/LibC/Uefi/Devices/Utility/Path.c
index d6728d3..fe19196 100644
--- a/StdLib/LibC/Uefi/Devices/Utility/Path.c
+++ b/StdLib/LibC/Uefi/Devices/Utility/Path.c
@@ -359,6 +359,7 @@ reclassify:
     }
     else if(MPath != NULL) {
       free(MPath);    /* Caller doesn't want it so let MPath go free */
+      MPath = NULL;
     }
 
     /*  At this point, WPath is an absolute path,
-- 
2.32.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79543): https://edk2.groups.io/g/devel/message/79543
Mute This Topic: https://groups.io/mt/84985779/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [edk2-libc Patch] StdLib/LibC/Uefi/Devices/Utility: Fix use after free
Posted by Rebecca Cran 2 years, 8 months ago
Reviewed-by: Rebecca Cran <rebecca@nuviainc.com>


-- 
Rebecca Cran

On 8/18/21 5:45 PM, Michael D Kinney wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=38
>
> Set MPath to NULL after free(MPath) to guarantee that MPath
> is not used after the free() call.
>
> Cc: Rebecca Cran <rebecca@nuviainc.com>
> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
> ---
>   StdLib/LibC/Uefi/Devices/Utility/Path.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/StdLib/LibC/Uefi/Devices/Utility/Path.c b/StdLib/LibC/Uefi/Devices/Utility/Path.c
> index d6728d3..fe19196 100644
> --- a/StdLib/LibC/Uefi/Devices/Utility/Path.c
> +++ b/StdLib/LibC/Uefi/Devices/Utility/Path.c
> @@ -359,6 +359,7 @@ reclassify:
>       }
>       else if(MPath != NULL) {
>         free(MPath);    /* Caller doesn't want it so let MPath go free */
> +      MPath = NULL;
>       }
>   
>       /*  At this point, WPath is an absolute path,


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79547): https://edk2.groups.io/g/devel/message/79547
Mute This Topic: https://groups.io/mt/84985779/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-