From: Andre Noll Date: Wed, 11 Aug 2021 19:37:16 +0000 (+0200) Subject: mp4: Hide ->read_error. X-Git-Tag: v0.7.1~7^2~92 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=5c633479e3b3b74a2090752543e9633cf36b313a;p=paraslash.git mp4: Hide ->read_error. This does not belong into the callback structure whose fields are supposed to get initialized by the audio format handler. Move it to the internal struct mp4 instead, next to the existing error counter. --- diff --git a/mp4.c b/mp4.c index da904aa8..991ba08d 100644 --- a/mp4.c +++ b/mp4.c @@ -52,6 +52,8 @@ struct mp4 { uint64_t moov_size; uint8_t last_atom; uint64_t file_size; + + uint32_t read_error; uint32_t error; /* incremental track index while reading the file */ @@ -76,7 +78,7 @@ static int32_t read_data(struct mp4 *f, void *data, uint32_t size) result = f->stream->read(f->stream->user_data, data, size); if (result < size) - f->stream->read_error++; + f->read_error++; f->current_position += size; @@ -444,7 +446,7 @@ static int32_t read_stsz(struct mp4 *f) if (t->stsz_sample_size != 0) return 0; t->stsz_table = para_malloc(t->stsz_sample_count * sizeof(int32_t)); - for (i = 0; i < t->stsz_sample_count && !f->stream->read_error; i++) + for (i = 0; i < t->stsz_sample_count && !f->read_error; i++) t->stsz_table[i] = read_int32(f); return 0; } @@ -469,7 +471,7 @@ static int32_t read_stts(struct mp4 *f) t->stts_sample_delta = para_malloc(t->stts_entry_count * sizeof (int32_t)); /* CVE-2017-9254 */ - for (i = 0; i < t->stts_entry_count && !f->stream->read_error; i++) { + for (i = 0; i < t->stts_entry_count && !f->read_error; i++) { t->stts_sample_count[i] = read_int32(f); t->stts_sample_delta[i] = read_int32(f); } @@ -495,7 +497,7 @@ static int32_t read_stsc(struct mp4 *f) sizeof (int32_t)); /* CVE-2017-9255 */ - for (i = 0; i < t->stsc_entry_count && !f->stream->read_error; i++) { + for (i = 0; i < t->stsc_entry_count && !f->read_error; i++) { t->stsc_first_chunk[i] = read_int32(f); t->stsc_samples_per_chunk[i] = read_int32(f); t->stsc_sample_desc_index[i] = read_int32(f); @@ -518,7 +520,7 @@ static int32_t read_stco(struct mp4 *f) t->stco_chunk_offset = para_malloc(t->stco_entry_count * sizeof(int32_t)); /* CVE-2017-9256 */ - for (i = 0; i < t->stco_entry_count && !f->stream->read_error; i++) + for (i = 0; i < t->stco_entry_count && !f->read_error; i++) t->stco_chunk_offset[i] = read_int32(f); return 0; } @@ -581,7 +583,7 @@ static int32_t read_stsd(struct mp4 *f) entry_count = read_int32(f); /* CVE-2017-9253 */ - for (i = 0; i < entry_count && !f->stream->read_error; i++) { + for (i = 0; i < entry_count && !f->read_error; i++) { uint64_t skip = get_position(f); uint64_t size; uint8_t atom_type = 0; @@ -817,7 +819,7 @@ static int32_t parse_tag(struct mp4 *f, uint8_t parent, int32_t size) for ( sumsize = 0; - sumsize < size && !f->stream->read_error; /* CVE-2017-9222 */ + sumsize < size && !f->read_error; /* CVE-2017-9222 */ set_position(f, destpos), sumsize += subsize ) { subsize = atom_read_header(f, &atom_type, &header_size); @@ -1039,7 +1041,7 @@ static int32_t parse_atoms(struct mp4 *f, int meta_only) uint8_t header_size = 0; f->file_size = 0; - f->stream->read_error = 0; + f->read_error = 0; while ((size = atom_read_header(f, &atom_type, &header_size)) != 0) { diff --git a/mp4.h b/mp4.h index a61ef97b..9946b0fd 100644 --- a/mp4.h +++ b/mp4.h @@ -4,7 +4,6 @@ struct mp4_callback { uint32_t (*seek)(void *user_data, uint64_t position); uint32_t (*truncate)(void *user_data); void *user_data; - uint32_t read_error; }; struct mp4_tag {