Unified · Split
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | #include "avformat.h" |
| 24 | +#include "avio_internal.h" | |
| 24 | 25 | #include "demux.h" |
| 25 | 26 | #include "internal.h" |
| 26 | 27 | #include "libavutil/intreadwrite.h" |
| @@ -139,12 +140,10 @@ static int read_extradata(AVFormatContext *s, const ArgoBRPStreamHeader *hdr, · 112 unmodified lines | ||
| 139 | 140 | |
| 140 | 141 | av_assert0(bufsz >= size); |
| 141 | 142 | |
| 142 | − if ((ret = avio_read(s->pb, buf, size)) < 0) | |
| 143 | + ret = ffio_read_size(s->pb, buf, size); | |
| 144 | + if (ret < 0) | |
| 143 | 145 | return ret; |
| 144 | 146 | |
| 145 | − if (ret != size) | |
| 146 | − return AVERROR(EIO); | |
| 147 | − | |
| 148 | 147 | return 0; |
| 149 | 148 | } |
| 150 | 149 | |
| @@ -155,10 +154,9 @@ static int argo_brp_read_header(AVFormatContext *s) · 4 unmodified lines | ||
| 155 | 154 | ArgoBRPDemuxContext *brp = s->priv_data; |
| 156 | 155 | uint8_t buf[FFMAX(BRP_MIN_BUFFER_SIZE, ASF_MIN_BUFFER_SIZE)]; |
| 157 | 156 | |
| 158 | − if ((ret = avio_read(pb, buf, BRP_FILE_HEADER_SIZE)) < 0) | |
| 157 | + ret = ffio_read_size(pb, buf, BRP_FILE_HEADER_SIZE); | |
| 158 | + if (ret < 0) | |
| 159 | 159 | return ret; |
| 160 | − else if (ret != BRP_FILE_HEADER_SIZE) | |
| 161 | − return AVERROR(EIO); | |
| 162 | 160 | |
| 163 | 161 | brp->fhdr.magic = AV_RL32(buf + 0); |
| 164 | 162 | brp->fhdr.num_streams = AV_RL32(buf + 4); |
| @@ -181,10 +179,9 @@ static int argo_brp_read_header(AVFormatContext *s) · 16 unmodified lines | ||
| 181 | 179 | if (!(st = avformat_new_stream(s, NULL))) |
| 182 | 180 | return AVERROR(ENOMEM); |
| 183 | 181 | |
| 184 | − if ((ret = avio_read(pb, buf, BRP_STREAM_HEADER_SIZE)) < 0) | |
| 182 | + ret = ffio_read_size(pb, buf, BRP_STREAM_HEADER_SIZE); | |
| 183 | + if (ret < 0) | |
| 185 | 184 | return ret; |
| 186 | − else if (ret != BRP_STREAM_HEADER_SIZE) | |
| 187 | − return AVERROR(EIO); | |
| 188 | 185 | |
| 189 | 186 | hdr->codec_id = AV_RL32(buf + 0); |
| 190 | 187 | hdr->id = AV_RL32(buf + 4); |
| @@ -286,10 +283,9 @@ static int argo_brp_read_header(AVFormatContext *s) · 95 unmodified lines | ||
| 286 | 283 | av_log(s, AV_LOG_TRACE, "Searching %d blocks for BASF...", BRP_BASF_LOOKAHEAD); |
| 287 | 284 | |
| 288 | 285 | for (i = 0; i < BRP_BASF_LOOKAHEAD; i++) { |
| 289 | − if ((ret = avio_read(pb, buf, BRP_BLOCK_HEADER_SIZE)) < 0) | |
| 286 | + ret = ffio_read_size(pb, buf, BRP_BLOCK_HEADER_SIZE); | |
| 287 | + if (ret < 0) | |
| 290 | 288 | return ret; |
| 291 | − else if (ret != BRP_BLOCK_HEADER_SIZE) | |
| 292 | − return AVERROR(EIO); | |
| 293 | 289 | |
| 294 | 290 | blk.stream_id = AV_RL32(buf + 0); |
| 295 | 291 | blk.start_ms = AV_RL32(buf + 4); |
| @@ -313,10 +309,9 @@ static int argo_brp_read_header(AVFormatContext *s) · 17 unmodified lines | ||
| 313 | 309 | if (blk.size < ASF_CHUNK_HEADER_SIZE) |
| 314 | 310 | return AVERROR_INVALIDDATA; |
| 315 | 311 | |
| 316 | − if ((ret = avio_read(pb, buf, ASF_CHUNK_HEADER_SIZE)) < 0) | |
| 312 | + ret = ffio_read_size(pb, buf, BRP_BLOCK_HEADER_SIZE); | |
| 313 | + if (ret < 0) | |
| 317 | 314 | return ret; |
| 318 | − else if (ret != ASF_CHUNK_HEADER_SIZE) | |
| 319 | − return AVERROR(EIO); | |
| 320 | 315 | |
| 321 | 316 | ff_argo_asf_parse_chunk_header(&brp->basf.ckhdr, buf); |
| 322 | 317 | |
| @@ -358,10 +353,9 @@ static int argo_brp_read_packet(AVFormatContext *s, AVPacket *pkt) · 35 unmodified lines | ||
| 358 | 353 | ArgoASFChunkHeader ckhdr; |
| 359 | 354 | int ret; |
| 360 | 355 | |
| 361 | − if ((ret = avio_read(s->pb, buf, BRP_BLOCK_HEADER_SIZE)) < 0) | |
| 356 | + ret = ffio_read_size(s->pb, buf, BRP_BLOCK_HEADER_SIZE); | |
| 357 | + if (ret < 0) | |
| 362 | 358 | return ret; |
| 363 | − else if (ret != BRP_BLOCK_HEADER_SIZE) | |
| 364 | − return AVERROR(EIO); | |
| 365 | 359 | |
| 366 | 360 | blk.stream_id = AV_RL32(buf + 0); |
| 367 | 361 | blk.start_ms = AV_RL32(buf + 4); |
| @@ -380,8 +374,9 @@ static int argo_brp_read_packet(AVFormatContext *s, AVPacket *pkt) · 12 unmodified lines | ||
| 380 | 374 | if (blk.size < ASF_CHUNK_HEADER_SIZE) |
| 381 | 375 | return AVERROR_INVALIDDATA; |
| 382 | 376 | |
| 383 | − if (avio_read(s->pb, buf, ASF_CHUNK_HEADER_SIZE) != ASF_CHUNK_HEADER_SIZE) | |
| 384 | − return AVERROR_INVALIDDATA; | |
| 377 | + ret = ffio_read_size(s->pb, buf, ASF_CHUNK_HEADER_SIZE); | |
| 378 | + if (ret < 0) | |
| 379 | + return ret; | |
| 385 | 380 | |
| 386 | 381 | ff_argo_asf_parse_chunk_header(&ckhdr, buf); |
| 387 | 382 | |
| @@ -25,6 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include "libavcodec/bytestream.h" |
| 26 | 26 | #include "libavcodec/flac.h" |
| 27 | 27 | #include "avformat.h" |
| 28 | +#include "avio_internal.h" | |
| 28 | 29 | #include "demux.h" |
| 29 | 30 | #include "flac_picture.h" |
| 30 | 31 | #include "internal.h" |
| @@ -100,11 +101,9 @@ static int flac_read_header(AVFormatContext *s) · 69 unmodified lines | ||
| 100 | 101 | if (!buffer) { |
| 101 | 102 | return AVERROR(ENOMEM); |
| 102 | 103 | } |
| 103 | − ret = avio_read(s->pb, buffer, metadata_size); | |
| 104 | + ret = ffio_read_size(s->pb, buffer, metadata_size); | |
| 104 | 105 | if (ret < 0) { |
| 105 | 106 | RETURN_ERROR(ret); |
| 106 | − } else if (ret != metadata_size) { | |
| 107 | − RETURN_ERROR(AVERROR_EOF); | |
| 108 | 107 | } |
| 109 | 108 | break; |
| 110 | 109 | /* skip metadata block for unsupported types */ |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | #include "config_components.h" |
| 23 | 23 | |
| 24 | 24 | #include "avformat.h" |
| 25 | +#include "avio_internal.h" | |
| 25 | 26 | #include "demux.h" |
| 26 | 27 | #include "internal.h" |
| 27 | 28 | #include "mux.h" |
| @@ -60,9 +61,11 @@ static int ilbc_read_header(AVFormatContext *s) · 32 unmodified lines | ||
| 60 | 61 | AVIOContext *pb = s->pb; |
| 61 | 62 | AVStream *st; |
| 62 | 63 | uint8_t header[9]; |
| 64 | + int ret; | |
| 63 | 65 | |
| 64 | − if (avio_read(pb, header, 9) != 9) | |
| 65 | − return AVERROR_INVALIDDATA; | |
| 66 | + ret = ffio_read_size(pb, header, 9); | |
| 67 | + if (ret < 0) | |
| 68 | + return ret; | |
| 66 | 69 | |
| 67 | 70 | st = avformat_new_stream(s, NULL); |
| 68 | 71 | if (!st) |
| @@ -35,6 +35,7 @@ · 34 unmodified lines | ||
| 35 | 35 | #include "libavutil/channel_layout.h" |
| 36 | 36 | #include "libavutil/intreadwrite.h" |
| 37 | 37 | #include "avformat.h" |
| 38 | +#include "avio_internal.h" | |
| 38 | 39 | #include "demux.h" |
| 39 | 40 | #include "internal.h" |
| 40 | 41 | |
| @@ -611,11 +612,13 @@ static int ipmovie_read_header(AVFormatContext *s) · 570 unmodified lines | ||
| 611 | 612 | unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE]; |
| 612 | 613 | int chunk_type, i; |
| 613 | 614 | uint8_t signature_buffer[sizeof(signature)]; |
| 615 | + int ret; | |
| 614 | 616 | |
| 615 | 617 | ipmovie->avf = s; |
| 616 | 618 | |
| 617 | − if (avio_read(pb, signature_buffer, sizeof(signature_buffer)) != sizeof(signature_buffer)) | |
| 618 | − return AVERROR_INVALIDDATA; | |
| 619 | + ret = ffio_read_size(pb, signature_buffer, sizeof(signature_buffer)); | |
| 620 | + if (ret < 0) | |
| 621 | + return ret; | |
| 619 | 622 | while (memcmp(signature_buffer, signature, sizeof(signature))) { |
| 620 | 623 | memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1); |
| 621 | 624 | signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb); |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | #include "libavutil/channel_layout.h" |
| 35 | 35 | #include "libavutil/intreadwrite.h" |
| 36 | 36 | #include "avformat.h" |
| 37 | +#include "avio_internal.h" | |
| 37 | 38 | #include "demux.h" |
| 38 | 39 | #include "internal.h" |
| 39 | 40 | |
| @@ -144,8 +145,9 @@ static int read_packet(AVFormatContext *s, · 104 unmodified lines | ||
| 144 | 145 | if (avio_feof(pb)) |
| 145 | 146 | return AVERROR_EOF; |
| 146 | 147 | |
| 147 | − if (avio_read(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) | |
| 148 | − return AVERROR(EIO); | |
| 148 | + ret = ffio_read_size(pb, preamble, MM_PREAMBLE_SIZE); | |
| 149 | + if (ret < 0) | |
| 150 | + return ret; | |
| 149 | 151 | |
| 150 | 152 | type = AV_RL16(&preamble[0]); |
| 151 | 153 | length = AV_RL16(&preamble[2]); |
| @@ -163,8 +165,9 @@ static int read_packet(AVFormatContext *s, · 11 unmodified lines | ||
| 163 | 165 | if ((ret = av_new_packet(pkt, length + MM_PREAMBLE_SIZE)) < 0) |
| 164 | 166 | return ret; |
| 165 | 167 | memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE); |
| 166 | − if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length) | |
| 167 | − return AVERROR(EIO); | |
| 168 | + ret = ffio_read_size(pb, pkt->data + MM_PREAMBLE_SIZE, length); | |
| 169 | + if (ret < 0) | |
| 170 | + return ret; | |
| 168 | 171 | pkt->size = length + MM_PREAMBLE_SIZE; |
| 169 | 172 | pkt->stream_index = 0; |
| 170 | 173 | if (type!=MM_TYPE_PALETTE) |
| @@ -566,9 +566,9 @@ redo: · 565 unmodified lines | ||
| 566 | 566 | static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 }; |
| 567 | 567 | unsigned char buf[8]; |
| 568 | 568 | |
| 569 | − ret = avio_read(s->pb, buf, 8); | |
| 570 | − if (ret != 8) | |
| 571 | − return AVERROR_INVALIDDATA; | |
| 569 | + ret = ffio_read_size(s->pb, buf, 8); | |
| 570 | + if (ret < 0) | |
| 571 | + return ret; | |
| 572 | 572 | avio_seek(s->pb, -8, SEEK_CUR); |
| 573 | 573 | if (!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1)) |
| 574 | 574 | codec_id = AV_CODEC_ID_CAVS; |
| @@ -62,6 +62,7 @@ · 61 unmodified lines | ||
| 62 | 62 | #include "libavutil/opt.h" |
| 63 | 63 | #include "avformat.h" |
| 64 | 64 | #include "avlanguage.h" |
| 65 | +#include "avio_internal.h" | |
| 65 | 66 | #include "demux.h" |
| 66 | 67 | #include "internal.h" |
| 67 | 68 | #include "mxf.h" |
| @@ -659,6 +660,7 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv · 591 unmodified lines | ||
| 659 | 660 | uint64_t plaintext_size; |
| 660 | 661 | uint8_t ivec[16]; |
| 661 | 662 | uint8_t tmpbuf[16]; |
| 663 | + int ret; | |
| 662 | 664 | int index; |
| 663 | 665 | int body_sid; |
| 664 | 666 | |
| @@ -696,8 +698,9 @@ static int mxf_decrypt_triplet(AVFormatContext *s, AVPacket *pkt, KLVPacket *klv · 31 unmodified lines | ||
| 696 | 698 | if (size < 32 || size - 32 < orig_size || (int)orig_size != orig_size) |
| 697 | 699 | return AVERROR_INVALIDDATA; |
| 698 | 700 | avio_read(pb, ivec, 16); |
| 699 | − if (avio_read(pb, tmpbuf, 16) != 16) | |
| 700 | − return AVERROR_INVALIDDATA; | |
| 701 | + ret = ffio_read_size(pb, tmpbuf, 16); | |
| 702 | + if (ret < 16) | |
| 703 | + return ret; | |
| 701 | 704 | if (mxf->aesc) |
| 702 | 705 | av_aes_crypt(mxf->aesc, tmpbuf, tmpbuf, 1, ivec, 1); |
| 703 | 706 | if (memcmp(tmpbuf, checkv, 16)) |
| @@ -753,6 +756,7 @@ static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size · 49 unmodified lines | ||
| 753 | 756 | uint64_t footer_partition; |
| 754 | 757 | uint32_t nb_essence_containers; |
| 755 | 758 | uint64_t this_partition; |
| 759 | + int ret; | |
| 756 | 760 | |
| 757 | 761 | if (mxf->partitions_count >= INT_MAX / 2) |
| 758 | 762 | return AVERROR_INVALIDDATA; |
| @@ -818,9 +822,10 @@ static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size · 59 unmodified lines | ||
| 818 | 822 | if (partition->body_offset < 0) |
| 819 | 823 | return AVERROR_INVALIDDATA; |
| 820 | 824 | |
| 821 | − if (avio_read(pb, op, sizeof(UID)) != sizeof(UID)) { | |
| 825 | + ret = ffio_read_size(pb, op, sizeof(UID)); | |
| 826 | + if (ret < 0) { | |
| 822 | 827 | av_log(mxf->fc, AV_LOG_ERROR, "Failed reading UID\n"); |
| 823 | − return AVERROR_INVALIDDATA; | |
| 828 | + return ret; | |
| 824 | 829 | } |
| 825 | 830 | nb_essence_containers = avio_rb32(pb); |
| 826 | 831 | |
| @@ -1552,12 +1557,14 @@ static int mxf_read_indirect_value(void *arg, AVIOContext *pb, int size) · 725 unmodified lines | ||
| 1552 | 1557 | { |
| 1553 | 1558 | MXFTaggedValue *tagged_value = arg; |
| 1554 | 1559 | uint8_t key[17]; |
| 1560 | + int ret; | |
| 1555 | 1561 | |
| 1556 | 1562 | if (size <= 17) |
| 1557 | 1563 | return 0; |
| 1558 | 1564 | |
| 1559 | − if (avio_read(pb, key, 17) != 17) | |
| 1560 | − return AVERROR_INVALIDDATA; | |
| 1565 | + ret = ffio_read_size(pb, key, 17); | |
| 1566 | + if (ret < 0) | |
| 1567 | + return ret; | |
| 1561 | 1568 | /* TODO: handle other types of of indirect values */ |
| 1562 | 1569 | if (memcmp(key, mxf_indirect_value_utf16le, 17) == 0) { |
| 1563 | 1570 | return mxf_read_utf16le_string(pb, size - 17, &tagged_value->value); |
| @@ -30,6 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | #include "libavutil/channel_layout.h" |
| 31 | 31 | #include "libavutil/intreadwrite.h" |
| 32 | 32 | #include "avformat.h" |
| 33 | +#include "avio_internal.h" | |
| 33 | 34 | #include "demux.h" |
| 34 | 35 | #include "riff.h" |
| 35 | 36 | |
| @@ -94,6 +95,7 @@ static int qcp_read_header(AVFormatContext *s) · 58 unmodified lines | ||
| 94 | 95 | QCPContext *c = s->priv_data; |
| 95 | 96 | AVStream *st = avformat_new_stream(s, NULL); |
| 96 | 97 | uint8_t buf[16]; |
| 98 | + int ret; | |
| 97 | 99 | int i; |
| 98 | 100 | unsigned nb_rates; |
| 99 | 101 | |
| @@ -105,8 +107,9 @@ static int qcp_read_header(AVFormatContext *s) · 5 unmodified lines | ||
| 105 | 107 | |
| 106 | 108 | st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; |
| 107 | 109 | st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; |
| 108 | − if (avio_read(pb, buf, 16) != 16) | |
| 109 | − return AVERROR_INVALIDDATA; | |
| 110 | + ret = ffio_read_size(pb, buf, 16); | |
| 111 | + if (ret < 0) | |
| 112 | + return ret; | |
| 110 | 113 | if (is_qcelp_13k_guid(buf)) { |
| 111 | 114 | st->codecpar->codec_id = AV_CODEC_ID_QCELP; |
| 112 | 115 | } else if (!memcmp(buf, guid_evrc, 16)) { |
| @@ -188,8 +188,9 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, · 187 unmodified lines | ||
| 188 | 188 | st->codecpar->ch_layout.nb_channels = avio_rb16(pb); |
| 189 | 189 | if (version == 5) { |
| 190 | 190 | ast->deint_id = avio_rl32(pb); |
| 191 | − if (avio_read(pb, buf, 4) != 4) | |
| 192 | − return AVERROR_INVALIDDATA; | |
| 191 | + ret = ffio_read_size(pb, buf, 4); | |
| 192 | + if (ret < 0) | |
| 193 | + return ret; | |
| 193 | 194 | buf[4] = 0; |
| 194 | 195 | } else { |
| 195 | 196 | AV_WL32(buf, 0); |
| @@ -816,10 +817,11 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb, · 620 unmodified lines | ||
| 816 | 817 | pkt->data[0] = 0; |
| 817 | 818 | AV_WL32(pkt->data + 1, 1); |
| 818 | 819 | AV_WL32(pkt->data + 5, 0); |
| 819 | − if ((ret = avio_read(pb, pkt->data + 9, len)) != len) { | |
| 820 | + ret = ffio_read_size(pb, pkt->data + 9, len); | |
| 821 | + if (ret < 0) { | |
| 820 | 822 | av_packet_unref(pkt); |
| 821 | 823 | av_log(s, AV_LOG_ERROR, "Failed to read %d bytes\n", len); |
| 822 | − return ret < 0 ? ret : AVERROR(EIO); | |
| 824 | + return ret; | |
| 823 | 825 | } |
| 824 | 826 | return 0; |
| 825 | 827 | } |
| @@ -856,8 +858,9 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb, · 30 unmodified lines | ||
| 856 | 858 | av_log(s, AV_LOG_ERROR, "outside videobufsize\n"); |
| 857 | 859 | return 1; |
| 858 | 860 | } |
| 859 | − if (avio_read(pb, vst->pkt.data + vst->videobufpos, len) != len) | |
| 860 | − return AVERROR(EIO); | |
| 861 | + ret = ffio_read_size(pb, vst->pkt.data + vst->videobufpos, len); | |
| 862 | + if (ret < 0) | |
| 863 | + return ret; | |
| 861 | 864 | vst->videobufpos += len; |
| 862 | 865 | rm->remaining_len-= len; |
| 863 | 866 | |
| @@ -96,10 +96,10 @@ static int tak_read_header(AVFormatContext *s) · 95 unmodified lines | ||
| 96 | 96 | memset(buffer + size - 3, 0, AV_INPUT_BUFFER_PADDING_SIZE); |
| 97 | 97 | |
| 98 | 98 | ffio_init_checksum(pb, tak_check_crc, 0xCE04B7U); |
| 99 | − ret = avio_read(pb, buffer, size - 3); | |
| 100 | − if (ret != size - 3) { | |
| 99 | + ret = ffio_read_size(pb, buffer, size - 3); | |
| 100 | + if (ret < 0) { | |
| 101 | 101 | av_freep(&buffer); |
| 102 | − return ret < 0 ? ret : AVERROR_INVALIDDATA; | |
| 102 | + return ret; | |
| 103 | 103 | } |
| 104 | 104 | if (ffio_get_checksum(s->pb) != avio_rb24(pb)) { |
| 105 | 105 | av_log(s, AV_LOG_ERROR, "%d metadata block CRC error.\n", type); |
| @@ -117,9 +117,9 @@ static int tak_read_header(AVFormatContext *s) · 11 unmodified lines | ||
| 117 | 117 | if (size != 19) |
| 118 | 118 | return AVERROR_INVALIDDATA; |
| 119 | 119 | ffio_init_checksum(pb, tak_check_crc, 0xCE04B7U); |
| 120 | − ret = avio_read(pb, md5, 16); | |
| 121 | − if (ret != 16) | |
| 122 | − return ret < 0 ? ret : AVERROR_INVALIDDATA; | |
| 120 | + ret = ffio_read_size(pb, md5, 16); | |
| 121 | + if (ret < 0) | |
| 122 | + return ret; | |
| 123 | 123 | if (ffio_get_checksum(s->pb) != avio_rb24(pb)) { |
| 124 | 124 | av_log(s, AV_LOG_ERROR, "MD5 metadata block CRC error.\n"); |
| 125 | 125 | if (s->error_recognition & AV_EF_EXPLODE) |
| @@ -567,8 +567,9 @@ static int viv_read_header(AVFormatContext *s) · 566 unmodified lines | ||
| 567 | 567 | v = avio_r8(pb); |
| 568 | 568 | avio_seek(pb, v, SEEK_CUR); |
| 569 | 569 | |
| 570 | − if (avio_read(pb, keybuffer, 187) != 187) | |
| 571 | − return AVERROR_INVALIDDATA; | |
| 570 | + ret = ffio_read_size(pb, keybuffer, 187); | |
| 571 | + if (ret < 0) | |
| 572 | + return ret; | |
| 572 | 573 | key = decode_key(keybuffer); |
| 573 | 574 | viv->sb_key = key; |
| 574 | 575 | |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | #include "avformat.h" |
| 23 | +#include "avio_internal.h" | |
| 23 | 24 | #include "demux.h" |
| 24 | 25 | #include "internal.h" |
| 25 | 26 | #include "libavutil/intreadwrite.h" |
| @@ -65,10 +66,10 @@ static int add_metadata(AVFormatContext *s, uint32_t tag, · 39 unmodified lines | ||
| 65 | 66 | if (!buf) |
| 66 | 67 | return AVERROR(ENOMEM); |
| 67 | 68 | |
| 68 | − ret = avio_read(s->pb, buf, len); | |
| 69 | − if (ret < 0 || ret != len) { | |
| 69 | + ret = ffio_read_size(s->pb, buf, len); | |
| 70 | + if (ret < 0) { | |
| 70 | 71 | av_free(buf); |
| 71 | − return ret < 0 ? ret : AVERROR_INVALIDDATA; | |
| 72 | + return ret; | |
| 72 | 73 | } |
| 73 | 74 | buf[len] = 0; |
| 74 | 75 | AV_WL32(key, tag); |
| @@ -259,11 +260,9 @@ static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt) · 184 unmodified lines | ||
| 259 | 260 | |
| 260 | 261 | pkt->data[0] = 8 - c->remaining_bits; // Number of bits to skip |
| 261 | 262 | pkt->data[1] = c->last_frame_bits; |
| 262 | − ret = avio_read(s->pb, pkt->data+2, size); | |
| 263 | − | |
| 264 | − if (ret != size) { | |
| 265 | − return AVERROR(EIO); | |
| 266 | − } | |
| 263 | + ret = ffio_read_size(s->pb, pkt->data + 2, size); | |
| 264 | + if (ret < 0) | |
| 265 | + return ret; | |
| 267 | 266 | |
| 268 | 267 | c->last_frame_bits = pkt->data[size+1]; |
| 269 | 268 | c->remaining_bits = (size << 3) - c->frame_bit_len + c->remaining_bits; |
| @@ -872,9 +872,12 @@ static int w64_read_header(AVFormatContext *s) · 871 unmodified lines | ||
| 872 | 872 | WAVDemuxContext *wav = s->priv_data; |
| 873 | 873 | AVStream *st; |
| 874 | 874 | uint8_t guid[16]; |
| 875 | − int ret; | |
| 875 | + int ret = ffio_read_size(pb, guid, 16); | |
| 876 | + | |
| 877 | + if (ret < 0) | |
| 878 | + return ret; | |
| 876 | 879 | |
| 877 | − if (avio_read(pb, guid, 16) != 16 || memcmp(guid, ff_w64_guid_riff, 16)) | |
| 880 | + if (memcmp(guid, ff_w64_guid_riff, 16)) | |
| 878 | 881 | return AVERROR_INVALIDDATA; |
| 879 | 882 | |
| 880 | 883 | /* riff + wave + fmt + sizes */ |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | #include "libavutil/mem.h" |
| 35 | 35 | #include "libavutil/time_internal.h" |
| 36 | 36 | #include "avformat.h" |
| 37 | +#include "avio_internal.h" | |
| 37 | 38 | #include "demux.h" |
| 38 | 39 | #include "internal.h" |
| 39 | 40 | #include "wtv.h" |
| @@ -774,6 +775,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p · 734 unmodified lines | ||
| 774 | 775 | { |
| 775 | 776 | WtvContext *wtv = s->priv_data; |
| 776 | 777 | AVIOContext *pb = wtv->pb; |
| 778 | + int ret; | |
| 777 | 779 | while (!avio_feof(pb)) { |
| 778 | 780 | ff_asf_guid g; |
| 779 | 781 | int len, sid, consumed; |
| @@ -846,8 +848,9 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p · 66 unmodified lines | ||
| 846 | 848 | } |
| 847 | 849 | |
| 848 | 850 | buf_size = FFMIN(len - consumed, sizeof(buf)); |
| 849 | − if (avio_read(pb, buf, buf_size) != buf_size) | |
| 850 | − return AVERROR_INVALIDDATA; | |
| 851 | + ret = ffio_read_size(pb, buf, buf_size); | |
| 852 | + if (ret < 0) | |
| 853 | + return ret; | |
| 851 | 854 | consumed += buf_size; |
| 852 | 855 | ff_parse_mpeg2_descriptor(s, st, 0, &pbuf, buf + buf_size, NULL, 0, 0, NULL); |
| 853 | 856 | } |