diff options
author | Mans Rullgard <mans@mansr.com> | 2011-07-03 17:50:38 +0100 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2011-07-03 18:19:18 +0100 |
commit | edf4dbff33d8ab5653ecc9124bf4333cf05bab2a (patch) | |
tree | 5b47e91226c7059e037408d07a3444e3b8ec6b2c /libavutil/md5.c | |
parent | ff993cd7fcdfeffcac10337c0c6b69c599060c2b (diff) | |
download | ffmpeg-edf4dbff33d8ab5653ecc9124bf4333cf05bab2a.tar.gz |
md5: fix test program
This makes the md5-test program print something meaningful and not
smash the stack.
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavutil/md5.c')
-rw-r--r-- | libavutil/md5.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/libavutil/md5.c b/libavutil/md5.c index 271d71f48f..b0c678bc27 100644 --- a/libavutil/md5.c +++ b/libavutil/md5.c @@ -162,21 +162,29 @@ void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len){ } #ifdef TEST -#include <stdio.h> -#include <inttypes.h> #undef printf +#include <stdio.h> + +static void print_md5(uint8_t *md5) +{ + int i; + for (i = 0; i < 16; i++) + printf("%02x", md5[i]); + printf("\n"); +} + int main(void){ - uint64_t md5val; + uint8_t md5val[16]; int i; uint8_t in[1000]; for(i=0; i<1000; i++) in[i]= i*i; - av_md5_sum( (uint8_t*)&md5val, in, 1000); printf("%"PRId64"\n", md5val); - av_md5_sum( (uint8_t*)&md5val, in, 63); printf("%"PRId64"\n", md5val); - av_md5_sum( (uint8_t*)&md5val, in, 64); printf("%"PRId64"\n", md5val); - av_md5_sum( (uint8_t*)&md5val, in, 65); printf("%"PRId64"\n", md5val); + av_md5_sum(md5val, in, 1000); print_md5(md5val); + av_md5_sum(md5val, in, 63); print_md5(md5val); + av_md5_sum(md5val, in, 64); print_md5(md5val); + av_md5_sum(md5val, in, 65); print_md5(md5val); for(i=0; i<1000; i++) in[i]= i % 127; - av_md5_sum( (uint8_t*)&md5val, in, 999); printf("%"PRId64"\n", md5val); + av_md5_sum(md5val, in, 999); print_md5(md5val); return 0; } |