libbacktrace patch committed: Another memcpy -> coff_read4 fix

Message ID CAOyqgcVv4rABsaVBM3XtBww8TDJ2oJWDgU7S1wQ6dogjn-TFKg@mail.gmail.com
State New
Headers show
Series
  • libbacktrace patch committed: Another memcpy -> coff_read4 fix
Related show

Commit Message

Ian Lance Taylor Jan. 25, 2018, 3:33 p.m.
This libbacktrace patch fixes another cases where memcpy was used in a
way that would leave some bytes uninitialized on a 64-bit system.
Committed to mainline.

Ian

2018-01-25  Ian Lance Taylor  <iant@golang.org>

* pecoff.c (coff_add): Another memcpy -> coff_read4 fix.

Patch

Index: pecoff.c
===================================================================
--- pecoff.c	(revision 257040)
+++ pecoff.c	(working copy)
@@ -631,10 +631,10 @@  coff_add (struct backtrace_state *state,
     goto fail;
 
   {
-    const char *vptr = (const char *)fhdr_view.data;
+    const unsigned char *vptr = fhdr_view.data;
 
     if (vptr[0] == 'M' && vptr[1] == 'Z')
-      memcpy (&fhdr_off, vptr + 0x3c, 4);
+      fhdr_off = coff_read4 (vptr + 0x3c);
     else
       fhdr_off = 0;
   }