Ticket #935: patchmovabsolute.diff

File patchmovabsolute.diff, 3.4 KB (added by Carl Eugen Hoyos, 14 years ago)
  • libavformat/isom.h

    diff --git a/libavformat/isom.h b/libavformat/isom.h
    index 8f92cae..9a2847d 100644
    a b typedef struct MOVStreamContext {  
    130130} MOVStreamContext;
    131131
    132132typedef struct MOVContext {
     133    AVClass *avclass;
    133134    AVFormatContext *fc;
    134135    int time_scale;
    135136    int64_t duration;     ///< duration of the longest track
    typedef struct MOVContext {  
    143144    unsigned trex_count;
    144145    int itunes_metadata;  ///< metadata are itunes style
    145146    int chapter_track;
     147    int use_absolute_path;
    146148} MOVContext;
    147149
    148150int ff_mp4_read_descr_len(AVIOContext *pb);
  • libavformat/mov.c

    diff --git a/libavformat/mov.c b/libavformat/mov.c
    index 3bb42fe..788cea0 100644
    a b  
    3030#include "libavutil/mathematics.h"
    3131#include "libavutil/avstring.h"
    3232#include "libavutil/dict.h"
     33#include "libavutil/opt.h"
    3334#include "avformat.h"
    3435#include "internal.h"
    3536#include "avio_internal.h"
    static void mov_build_index(MOVContext *mov, AVStream *st)  
    19311932}
    19321933
    19331934static int mov_open_dref(AVIOContext **pb, const char *src, MOVDref *ref,
    1934                          AVIOInterruptCB *int_cb)
     1935                         AVIOInterruptCB *int_cb, int use_absolute_path)
    19351936{
    19361937    /* try relative path, we do not try the absolute because it can leak information about our
    19371938       system to an attacker */
    static int mov_open_dref(AVIOContext **pb, const char *src, MOVDref *ref,  
    19691970            if (!avio_open2(pb, filename, AVIO_FLAG_READ, int_cb, NULL))
    19701971                return 0;
    19711972        }
     1973    } else if (use_absolute_path) {
     1974        if (!avio_open2(pb, ref->path, AVIO_FLAG_READ, int_cb, NULL))
     1975            return 0;
    19721976    }
    19731977
    19741978    return AVERROR(ENOENT);
    static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)  
    20212025
    20222026    if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) {
    20232027        MOVDref *dref = &sc->drefs[sc->dref_id - 1];
    2024         if (mov_open_dref(&sc->pb, c->fc->filename, dref, &c->fc->interrupt_callback) < 0)
     2028        if (mov_open_dref(&sc->pb, c->fc->filename, dref, &c->fc->interrupt_callback,
     2029            c->use_absolute_path) < 0)
    20252030            av_log(c->fc, AV_LOG_ERROR,
    20262031                   "stream %d, error opening alias: path='%s', dir='%s', "
    20272032                   "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
    static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)  
    27402745    AVIndexEntry *sample;
    27412746    AVStream *st = NULL;
    27422747    int ret;
     2748    mov->fc = s;
    27432749 retry:
    27442750    sample = mov_find_next_sample(s, &st);
    27452751    if (!sample) {
    static int mov_read_close(AVFormatContext *s)  
    29092915    return 0;
    29102916}
    29112917
     2918static const AVOption options[]={
     2919{"use_absolute_path", "allow using absolute path when opening alias", offsetof(MOVContext, use_absolute_path), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_DECODING_PARAM},
     2920{NULL}
     2921};
     2922static const AVClass class = { "mov,mp4,m4a,3gp,3g2,mj2", av_default_item_name, options, LIBAVUTIL_VERSION_INT };
     2923
    29122924AVInputFormat ff_mov_demuxer = {
    29132925    .name           = "mov,mp4,m4a,3gp,3g2,mj2",
    29142926    .long_name      = NULL_IF_CONFIG_SMALL("QuickTime/MPEG-4/Motion JPEG 2000 format"),
    AVInputFormat ff_mov_demuxer = {  
    29182930    .read_packet    = mov_read_packet,
    29192931    .read_close     = mov_read_close,
    29202932    .read_seek      = mov_read_seek,
     2933    .priv_class     = &class,
    29212934};