X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fnistspheredec.c;h=b606ce72aa8766950d4b62d0680fdcc54cef1186;hb=bc70684e74a185d7b80c8b80bdedda659cb581b8;hp=55f22ebcf4f0ea052167e6ccd6c0e16ea0bb5b00;hpb=fb4a12cda4033f2f3d3d1039739f6e0e6f9afb82;p=ffmpeg diff --git a/libavformat/nistspheredec.c b/libavformat/nistspheredec.c index 55f22ebcf4f..b606ce72aa8 100644 --- a/libavformat/nistspheredec.c +++ b/libavformat/nistspheredec.c @@ -25,7 +25,7 @@ #include "internal.h" #include "pcm.h" -static int nist_probe(AVProbeData *p) +static int nist_probe(const AVProbeData *p) { if (AV_RL64(p->buf) == AV_RL64("NIST_1A\x0a")) return AVPROBE_SCORE_MAX; @@ -90,6 +90,8 @@ static int nist_read_header(AVFormatContext *s) return 0; } else if (!memcmp(buffer, "channel_count", 13)) { sscanf(buffer, "%*s %*s %u", &st->codecpar->channels); + if (st->codecpar->channels <= 0 || st->codecpar->channels > INT16_MAX) + return AVERROR_INVALIDDATA; } else if (!memcmp(buffer, "sample_byte_format", 18)) { sscanf(buffer, "%*s %*s %31s", format); @@ -109,10 +111,14 @@ static int nist_read_header(AVFormatContext *s) sscanf(buffer, "%*s %*s %"SCNd64, &st->duration); } else if (!memcmp(buffer, "sample_n_bytes", 14)) { sscanf(buffer, "%*s %*s %d", &bps); + if (bps > INT16_MAX/8U) + return AVERROR_INVALIDDATA; } else if (!memcmp(buffer, "sample_rate", 11)) { sscanf(buffer, "%*s %*s %d", &st->codecpar->sample_rate); } else if (!memcmp(buffer, "sample_sig_bits", 15)) { sscanf(buffer, "%*s %*s %d", &st->codecpar->bits_per_coded_sample); + if (st->codecpar->bits_per_coded_sample <= 0 || st->codecpar->bits_per_coded_sample > INT16_MAX) + return AVERROR_INVALIDDATA; } else { char key[32], value[32]; if (sscanf(buffer, "%31s %*s %31s", key, value) == 2) { @@ -126,7 +132,7 @@ static int nist_read_header(AVFormatContext *s) return AVERROR_EOF; } -AVInputFormat ff_nistsphere_demuxer = { +const AVInputFormat ff_nistsphere_demuxer = { .name = "nistsphere", .long_name = NULL_IF_CONFIG_SMALL("NIST SPeech HEader REsources"), .read_probe = nist_probe,