aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVesselin Bontchev <vesselin.bontchev@yandex.com>2015-08-25 12:37:02 +0000
committerVesselin Bontchev <vesselin.bontchev@yandex.com>2015-08-25 12:44:20 +0000
commit4cd1d2314beec9ab6f96a1c820be62d642e99298 (patch)
treeff05d6c9aaf4114a8cbe8b5cf28ab79fcf8b5f7a
parent83a508cda5115c61b456aeb227bf770d61010961 (diff)
downloadffmpeg-4cd1d2314beec9ab6f96a1c820be62d642e99298.tar.gz
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.
-rw-r--r--libavformat/aadec.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libavformat/aadec.c b/libavformat/aadec.c
index 8e6140e189..ba700d5168 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);