[FFmpeg-cvslog] avformat/aa: use correct format specifier in sscanf
Vesselin Bontchev
git at videolan.org
Tue Aug 25 14:58:25 CEST 2015
ffmpeg | branch: master | Vesselin Bontchev <vesselin.bontchev at yandex.com> | Tue Aug 25 12:37:02 2015 +0000| [4cd1d2314beec9ab6f96a1c820be62d642e99298] | committer: Vesselin Bontchev
avformat/aa: use correct format specifier in sscanf
This demuxer was broken on a large number of platforms due to usage of wrong
format specifier in sscanf. This patch fixes the problem, and also adds some
debug logging to reduce future debugging pain.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4cd1d2314beec9ab6f96a1c820be62d642e99298
---
libavformat/aadec.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/libavformat/aadec.c b/libavformat/aadec.c
index 8e6140e..ba700d5 100644
--- a/libavformat/aadec.c
+++ b/libavformat/aadec.c
@@ -112,16 +112,23 @@ static int aa_read_header(AVFormatContext *s)
avio_read(pb, val, nval); // value string
}
if (!strcmp(key, "codec")) {
+ av_log(s, AV_LOG_DEBUG, "Codec is <%s>\n", val);
strncpy(codec_name, val, sizeof(codec_name) - 1);
}
if (!strcmp(key, "HeaderSeed")) {
+ av_log(s, AV_LOG_DEBUG, "HeaderSeed is <%s>\n", val);
header_seed = atoi(val);
}
if (!strcmp(key, "HeaderKey")) { // this looks like "1234567890 1234567890 1234567890 1234567890"
- sscanf(val, "%d%d%d%d", &header_key_part[0], &header_key_part[1], &header_key_part[2], &header_key_part[3]);
+ av_log(s, AV_LOG_DEBUG, "HeaderKey is <%s>\n", val);
+ sscanf(val, "%u%u%u%u", &header_key_part[0], &header_key_part[1], &header_key_part[2], &header_key_part[3]);
for (idx = 0; idx < 4; idx++) {
AV_WB32(&header_key[idx * 4], header_key_part[idx]); // convert each part to BE!
}
+ av_log(s, AV_LOG_DEBUG, "Processed HeaderKey is ");
+ for (i = 0; i < 16; i++)
+ av_log(s, AV_LOG_DEBUG, "%02x", header_key[i]);
+ av_log(s, AV_LOG_DEBUG, "\n");
}
}
@@ -143,7 +150,7 @@ static int aa_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
av_tea_init(c->tea_ctx, c->aa_fixed_key, 16);
output[0] = output[1] = 0; // purely for padding purposes
- memcpy(output + 2, &header_key, 16);
+ memcpy(output + 2, header_key, 16);
idx = 0;
for (i = 0; i < 3; i++) { // TEA CBC with weird mixed endianness
AV_WB32(src, header_seed);
@@ -155,6 +162,10 @@ static int aa_read_header(AVFormatContext *s)
}
}
memcpy(c->file_key, output + 2, 16); // skip first 2 bytes of output
+ av_log(s, AV_LOG_DEBUG, "File key is ");
+ for (i = 0; i < 16; i++)
+ av_log(s, AV_LOG_DEBUG, "%02x", c->file_key[i]);
+ av_log(s, AV_LOG_DEBUG, "\n");
/* decoder setup */
st = avformat_new_stream(s, NULL);
More information about the ffmpeg-cvslog
mailing list