Browse code

Make SHA digest function write digest value with AV_WN32 instead of assuming that output may be written as uint32_t since output buffer may not be aligned (and it's silly to force alignment on it) and it does not work in that case properly on some architectures.

Originally committed as revision 21754 to svn://svn.ffmpeg.org/ffmpeg/trunk

Kostya Shishkov authored on 2010/02/11 20:45:35
Showing 1 changed files
... ...
@@ -25,6 +25,7 @@
25 25
 #include "avutil.h"
26 26
 #include "bswap.h"
27 27
 #include "sha.h"
28
+#include "intreadwrite.h"
28 29
 
29 30
 /** hash context */
30 31
 typedef struct AVSHA {
... ...
@@ -319,7 +320,7 @@ void av_sha_final(AVSHA* ctx, uint8_t *digest)
319 319
         av_sha_update(ctx, "", 1);
320 320
     av_sha_update(ctx, (uint8_t *)&finalcount, 8); /* Should cause a transform() */
321 321
     for (i = 0; i < ctx->digest_len; i++)
322
-        ((uint32_t*)digest)[i] = be2me_32(ctx->state[i]);
322
+        AV_WN32(digest + i*4, be2me_32(ctx->state[i]));
323 323
 }
324 324
 
325 325
 #if LIBAVUTIL_VERSION_MAJOR < 51