From 07cd425c2550569c23e203df2bc878640f8e6c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 27 Feb 2008 10:42:08 +0000 Subject: [PATCH] gst-libs/gst/cdda/sha1.c: Use memcpy() instead of upcasting a byte array to long *. This fixes an unaligned memory ac... Original commit message from CVS: * gst-libs/gst/cdda/sha1.c: (sha_transform): Use memcpy() instead of upcasting a byte array to long *. This fixes an unaligned memory access, resulting in SIGBUS on IA64. This should be ported to GCheckSum once we can use GLib 2.16. Partially fixes bug #500833. --- ChangeLog | 8 ++++++++ gst-libs/gst/cdda/sha1.c | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e9e7c04ca4..79dbeeb9ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-02-27 Sebastian Dröge + + * gst-libs/gst/cdda/sha1.c: (sha_transform): + Use memcpy() instead of upcasting a byte array to long *. This + fixes an unaligned memory access, resulting in SIGBUS on IA64. + This should be ported to GCheckSum once we can use GLib 2.16. + Partially fixes bug #500833. + 2008-02-27 Tim-Philipp Müller * gst-libs/gst/tag/gsttagdemux.c: (gst_tag_demux_chain): diff --git a/gst-libs/gst/cdda/sha1.c b/gst-libs/gst/cdda/sha1.c index d406bad314..41f5f85a41 100644 --- a/gst-libs/gst/cdda/sha1.c +++ b/gst-libs/gst/cdda/sha1.c @@ -99,7 +99,7 @@ nether regions of the anatomy... #if (SHA_BYTE_ORDER == 1234) #define SWAP_DONE for (i = 0; i < 16; ++i) { - T = *((SHA_LONG *) dp); + memcpy (&T, dp, sizeof (SHA_LONG)); dp += 4; W[i] = ((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) | ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff); @@ -109,7 +109,7 @@ nether regions of the anatomy... #if (SHA_BYTE_ORDER == 4321) #define SWAP_DONE for (i = 0; i < 16; ++i) { - T = *((SHA_LONG *) dp); + memcpy (&T, dp, sizeof (SHA_LONG)); dp += 4; W[i] = T32 (T); } @@ -118,7 +118,7 @@ nether regions of the anatomy... #if (SHA_BYTE_ORDER == 12345678) #define SWAP_DONE for (i = 0; i < 16; i += 2) { - T = *((SHA_LONG *) dp); + memcpy (&T, dp, sizeof (SHA_LONG)); dp += 8; W[i] = ((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) | ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff); @@ -131,7 +131,7 @@ nether regions of the anatomy... #if (SHA_BYTE_ORDER == 87654321) #define SWAP_DONE for (i = 0; i < 16; i += 2) { - T = *((SHA_LONG *) dp); + memcpy (&T, dp, sizeof (SHA_LONG)); dp += 8; W[i] = T32 (T >> 32); W[i + 1] = T32 (T);