aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/asfcrypt.c
diff options
context:
space:
mode:
authorMåns Rullgård <mans@mansr.com>2010-08-24 13:42:28 +0000
committerMåns Rullgård <mans@mansr.com>2010-08-24 13:42:28 +0000
commitac9c19da66b54e690f17001e7eb855bae5f23d0d (patch)
tree01a3bfbf71e210bfda442cdc62c86721a66aedd5 /libavformat/asfcrypt.c
parent7f1af825f8bbb2fd911284a68f1c98e784e0fda4 (diff)
downloadffmpeg-ac9c19da66b54e690f17001e7eb855bae5f23d0d.tar.gz
asfcrypt: fix unaligned accesses with armcc
Compilers may assume a pointer has natural alignment, even if it was assigned from a pointer type with weaker alignment requirements. It is thus not safe to assign a possibly unaligned value to a pointer, regardless of how it is subsequently dereferenced. Originally committed as revision 24897 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/asfcrypt.c')
-rw-r--r--libavformat/asfcrypt.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libavformat/asfcrypt.c b/libavformat/asfcrypt.c
index cb3516fc50..59986e0a2c 100644
--- a/libavformat/asfcrypt.c
+++ b/libavformat/asfcrypt.c
@@ -139,7 +139,7 @@ void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len) {
struct AVDES des;
struct AVRC4 rc4;
int num_qwords = len >> 3;
- uint64_t *qwords = (uint64_t *)data;
+ uint8_t *qwords = data;
uint64_t rc4buff[8];
uint64_t packetkey;
uint32_t ms_keys[12];
@@ -156,7 +156,7 @@ void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len) {
av_rc4_crypt(&rc4, (uint8_t *)rc4buff, NULL, sizeof(rc4buff), NULL, 1);
multiswap_init((uint8_t *)rc4buff, ms_keys);
- packetkey = AV_RN64(&qwords[num_qwords - 1]);
+ packetkey = AV_RN64(&qwords[num_qwords*8 - 8]);
packetkey ^= rc4buff[7];
av_des_init(&des, key + 12, 64, 1);
av_des_crypt(&des, (uint8_t *)&packetkey, (uint8_t *)&packetkey, 1, NULL, 1);
@@ -166,7 +166,7 @@ void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len) {
av_rc4_crypt(&rc4, data, data, len, NULL, 1);
ms_state = 0;
- for (i = 0; i < num_qwords - 1; i++, qwords++)
+ for (i = 0; i < num_qwords - 1; i++, qwords += 8)
ms_state = multiswap_enc(ms_keys, ms_state, AV_RL64(qwords));
multiswap_invert_keys(ms_keys);
packetkey = (packetkey << 32) | (packetkey >> 32);