]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Avoid modifying PE/COFF debug filename
authorMichael Brown <mcb30@ipxe.org>
Wed, 29 Nov 2023 12:49:06 +0000 (12:49 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 29 Nov 2023 12:49:06 +0000 (12:49 +0000)
The function efi_pecoff_debug_name() (called by efi_handle_name()) is
used to extract a filename from the debug data directory entry located
within a PE/COFF image.  The name is copied into a temporary static
buffer to allow for modifications, but the code currently erroneously
modifies the original name within the loaded PE/COFF image.

Fix by performing the modification on the copy in the temporary
buffer, as originally intended.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/interface/efi/efi_debug.c

index 1372776fe312001b8aa89058817f383492d5abfa..ad79f0d370b2570b1faaca49a3ae467771dd2671 100644 (file)
@@ -665,10 +665,10 @@ efi_pecoff_debug_name ( EFI_LOADED_IMAGE_PROTOCOL *loaded ) {
        snprintf ( buf, sizeof ( buf ), "%s", name );
 
        /* Strip file suffix, if present */
-       if ( ( tmp = strrchr ( name, '.' ) ) != NULL )
+       if ( ( tmp = strrchr ( buf, '.' ) ) != NULL )
                *tmp = '\0';
 
-       return name;
+       return buf;
 }
 
 /**