- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- st->codec->width = get_be16(pb);
- st->codec->height = get_be16(pb);
- url_fskip(pb, 4); // x, y offset
- st->codec->bits_per_coded_sample = get_byte(pb);
- url_fskip(pb, 1); // masking
- compression = get_byte(pb);
- url_fskip(pb, 3); // paddding, transparent
- st->sample_aspect_ratio.num = get_byte(pb);
- st->sample_aspect_ratio.den = get_byte(pb);
- url_fskip(pb, 4); // source page width, height
+ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ if (data_size <= 8)
+ return AVERROR_INVALIDDATA;
+ st->codecpar->width = avio_rb16(pb);
+ st->codecpar->height = avio_rb16(pb);
+ avio_skip(pb, 4); // x, y offset
+ st->codecpar->bits_per_coded_sample = avio_r8(pb);
+ if (data_size >= 11) {
+ avio_skip(pb, 1); // masking
+ compression = avio_r8(pb);
+ }
+ if (data_size >= 16) {
+ avio_skip(pb, 3); // padding, transparent
+ st->sample_aspect_ratio.num = avio_r8(pb);
+ st->sample_aspect_ratio.den = avio_r8(pb);
+ }