* by Robin Kay (komadori at gekkou.co.uk)
*/
+#include <inttypes.h>
+
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "internal.h"
break;
case 0x8A:
av_log(s, AV_LOG_DEBUG,
- "element 0x%02x set to 0x%08x\n",
+ "element 0x%02x set to 0x%08"PRIx32"\n",
subbyte, read_arbitrary(pb));
av_log(s, AV_LOG_DEBUG, "exited audio subheader\n");
in_subheader = 0;
break;
default:
av_log(s, AV_LOG_DEBUG,
- "element 0x%02x set to 0x%08x\n",
+ "element 0x%02x set to 0x%08"PRIx32"\n",
subbyte, read_arbitrary(pb));
break;
}
break;
default:
av_log(s, AV_LOG_DEBUG,
- "header element 0x%02x set to 0x%08x\n",
+ "header element 0x%02x set to 0x%08"PRIx32"\n",
byte, read_arbitrary(pb));
break;
}
}
if (ea->audio_codec) {
- if (ea->num_channels <= 0) {
+ if (ea->num_channels <= 0 || ea->num_channels > 2) {
av_log(s, AV_LOG_WARNING,
"Unsupported number of channels: %d\n", ea->num_channels);
ea->audio_codec = 0;
case AV_CODEC_ID_ADPCM_EA_R1:
case AV_CODEC_ID_ADPCM_EA_R2:
case AV_CODEC_ID_ADPCM_IMA_EA_EACS:
- pkt->duration = AV_RL32(pkt->data);
- break;
case AV_CODEC_ID_ADPCM_EA_R3:
- pkt->duration = AV_RB32(pkt->data);
+ if (pkt->size < 4) {
+ av_log(s, AV_LOG_ERROR, "Packet is too short\n");
+ av_free_packet(pkt);
+ return AVERROR_INVALIDDATA;
+ }
+ if (ea->audio_codec == AV_CODEC_ID_ADPCM_EA_R3)
+ pkt->duration = AV_RB32(pkt->data);
+ else
+ pkt->duration = AV_RL32(pkt->data);
break;
case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
pkt->duration = ret * 2 / ea->num_channels;