| 71 | } |
| 72 | |
| 73 | static int parse_utf(AVFormatContext *s, AVIOContext *pb, |
| 74 | USMChannel *ch, int ch_type, |
| 75 | uint32_t parent_chunk_size) |
| 76 | { |
| 77 | USMDemuxContext *usm = s->priv_data; |
| 78 | GetByteContext gb, ugb, sgb; |
| 79 | uint32_t chunk_type, chunk_size, offset; |
| 80 | uint32_t unique_offset, string_offset; |
| 81 | int nb_items, unique_size, nb_dictionaries; |
| 82 | AVRational fps = { 0 }; |
| 83 | int type; |
| 84 | |
| 85 | chunk_type = avio_rb32(pb); |
| 86 | chunk_size = avio_rb32(pb); |
| 87 | |
| 88 | if (chunk_type != MKBETAG('@','U','T','F')) |
| 89 | return AVERROR_INVALIDDATA; |
| 90 | |
| 91 | if (!chunk_size || chunk_size >= parent_chunk_size) |
| 92 | return AVERROR_INVALIDDATA; |
| 93 | |
| 94 | av_fast_malloc(&usm->header, &usm->header_size, chunk_size); |
| 95 | if (!usm->header) |
| 96 | return AVERROR(ENOMEM); |
| 97 | |
| 98 | if (avio_read(pb, usm->header, chunk_size) != chunk_size) |
| 99 | return AVERROR_EOF; |
| 100 | |
| 101 | bytestream2_init(&gb, usm->header, chunk_size); |
| 102 | ugb = gb; |
| 103 | sgb = gb; |
| 104 | unique_offset = bytestream2_get_be32(&gb); |
| 105 | string_offset = bytestream2_get_be32(&gb); |
| 106 | /*byte_offset =*/ bytestream2_get_be32(&gb); |
| 107 | /*payload_name_offset =*/ bytestream2_get_be32(&gb); |
| 108 | nb_items = bytestream2_get_be16(&gb); |
| 109 | unique_size = bytestream2_get_be16(&gb); |
| 110 | nb_dictionaries = bytestream2_get_be32(&gb); |
| 111 | if (nb_dictionaries == 0) |
| 112 | return AVERROR_INVALIDDATA; |
| 113 | |
| 114 | bytestream2_skip(&ugb, unique_offset); |
| 115 | if (bytestream2_get_bytes_left(&ugb) < unique_size) |
| 116 | return AVERROR_INVALIDDATA; |
| 117 | bytestream2_init(&ugb, ugb.buffer, unique_size); |
| 118 | |
| 119 | bytestream2_skip(&sgb, string_offset); |
| 120 | |
| 121 | for (int i = 0; i < nb_items; i++) { |
| 122 | GetByteContext *xgb; |
| 123 | uint8_t key[256]; |
| 124 | int64_t value = -1; |
| 125 | int n = 0; |
| 126 | |
| 127 | type = bytestream2_get_byte(&gb); |
| 128 | offset = bytestream2_get_be32(&gb); |
| 129 | |
| 130 | bytestream2_seek(&sgb, string_offset + offset, SEEK_SET); |
no test coverage detected