int ret, dref_id = 1;
MOVAtom a = { AV_RL32("stsd") };
int64_t start_pos = avio_tell(pb);
- int64_t size = avio_rb32(pb); /* size */
+ int64_t size = avio_rb32(pb); /* size */
uint32_t format = avio_rl32(pb); /* data format */
if (size >= 16) {
return 1;
}
-static int mov_open_dref(MOVContext *c, AVIOContext **pb, const char *src, MOVDref *ref,
- AVIOInterruptCB *int_cb)
+static int mov_open_dref(MOVContext *c, AVIOContext **pb, const char *src, MOVDref *ref)
{
- AVOpenCallback open_func = c->fc->open_cb;
-
- if (!open_func)
- open_func = ffio_open2_wrapper;
-
/* try relative path, we do not try the absolute because it can leak information about our
system to an attacker */
if (ref->nlvl_to > 0 && ref->nlvl_from > 0) {
av_strlcat(filename, "../", sizeof(filename));
av_strlcat(filename, ref->path + l + 1, sizeof(filename));
- if (!c->use_absolute_path && !c->fc->open_cb) {
+ if (!c->use_absolute_path) {
int same_origin = test_same_origin(src, filename);
if (!same_origin) {
if (strlen(filename) + 1 == sizeof(filename))
return AVERROR(ENOENT);
- if (!open_func(c->fc, pb, filename, AVIO_FLAG_READ, int_cb, NULL))
+ if (!c->fc->io_open(c->fc, pb, filename, AVIO_FLAG_READ, NULL))
return 0;
}
} else if (c->use_absolute_path) {
av_log(c->fc, AV_LOG_WARNING, "Using absolute path on user request, "
"this is a possible security issue\n");
- if (!open_func(c->fc, pb, ref->path, AVIO_FLAG_READ, int_cb, NULL))
- return 0;
- } else if (c->fc->open_cb) {
- if (!open_func(c->fc, pb, ref->path, AVIO_FLAG_READ, int_cb, NULL))
+ if (!c->fc->io_open(c->fc, pb, ref->path, AVIO_FLAG_READ, NULL))
return 0;
} else {
av_log(c->fc, AV_LOG_ERROR,
if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) {
MOVDref *dref = &sc->drefs[sc->dref_id - 1];
if (c->enable_drefs) {
- if (mov_open_dref(c, &sc->pb, c->fc->filename, dref,
- &c->fc->interrupt_callback) < 0)
+ if (mov_open_dref(c, &sc->pb, c->fc->filename, dref) < 0)
av_log(c->fc, AV_LOG_ERROR,
"stream %d, error opening alias: path='%s', dir='%s', "
"filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
return 0;
}
-static int mov_read_custom_2plus(MOVContext *c, AVIOContext *pb, int size)
+static int mov_read_custom_2plus(MOVContext *c, AVIOContext *pb, int64_t size)
{
int64_t end = avio_tell(pb) + size;
uint8_t *key = NULL, *val = NULL;
0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
};
+ static const uint8_t uuid_xmp[] = {
+ 0xbe, 0x7a, 0xcf, 0xcb, 0x97, 0xa9, 0x42, 0xe8,
+ 0x9c, 0x71, 0x99, 0x94, 0x91, 0xe3, 0xaf, 0xac
+ };
if (atom.size < sizeof(uuid) || atom.size == INT64_MAX)
return AVERROR_INVALIDDATA;
}
}
+ av_free(buffer);
+ } else if (!memcmp(uuid, uuid_xmp, sizeof(uuid))) {
+ uint8_t *buffer;
+ size_t len = atom.size - sizeof(uuid);
+
+ buffer = av_mallocz(len + 1);
+ if (!buffer) {
+ return AVERROR(ENOMEM);
+ }
+ ret = avio_read(pb, buffer, len);
+ if (ret < 0) {
+ av_free(buffer);
+ return ret;
+ } else if (ret != len) {
+ av_free(buffer);
+ return AVERROR_INVALIDDATA;
+ }
+ if (c->export_xmp) {
+ buffer[len] = '\0';
+ av_dict_set(&c->fc->metadata, "xmp", buffer, 0);
+ }
av_free(buffer);
}
return 0;
break;
default:
- av_log(c->fc, AV_LOG_WARNING,
- "ignoring 'frma' atom of '%.4s', stream format is '%.4s'\n",
- (char*)&format, (char*)&sc->format);
+ if (format != sc->format) {
+ av_log(c->fc, AV_LOG_WARNING,
+ "ignoring 'frma' atom of '%.4s', stream format is '%.4s'\n",
+ (char*)&format, (char*)&sc->format);
+ }
break;
}
sc->drefs_count = 0;
if (!sc->pb_is_copied)
- avio_closep(&sc->pb);
+ ff_format_io_close(s, &sc->pb);
sc->pb = NULL;
av_freep(&sc->chunk_offsets);