diff mbox series

[v4,13/19] contrib/elf2dmp: Use lduw_le_p() to read PDB

Message ID 20240307-elf2dmp-v4-13-4f324ad4d99d@daynix.com
State New
Headers show
Series contrib/elf2dmp: Improve robustness | expand

Commit Message

Akihiko Odaki March 7, 2024, 10:20 a.m. UTC
The relevant value may be unaligned and is little-endian.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 contrib/elf2dmp/pdb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé March 7, 2024, 10:27 a.m. UTC | #1
On 7/3/24 11:20, Akihiko Odaki wrote:
> The relevant value may be unaligned and is little-endian.
> 

Fixes: 231f6a7d66 ("elf2dmp: rework PDB_STREAM_INDEXES::segments obtaining")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
>   contrib/elf2dmp/pdb.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
index 1c5051425185..492aca4434c8 100644
--- a/contrib/elf2dmp/pdb.c
+++ b/contrib/elf2dmp/pdb.c
@@ -19,6 +19,7 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu/bswap.h"
 
 #include "pdb.h"
 #include "err.h"
@@ -186,7 +187,7 @@  static bool pdb_init_symbols(struct pdb_reader *r)
 
     r->symbols = symbols;
 
-    r->segments = *(uint16_t *)((const char *)symbols + sizeof(PDB_SYMBOLS) +
+    r->segments = lduw_le_p((const char *)symbols + sizeof(PDB_SYMBOLS) +
             symbols->module_size + symbols->offset_size +
             symbols->hash_size + symbols->srcmodule_size +
             symbols->pdbimport_size + symbols->unknown2_size +