static int mov_open_dref(AVIOContext **pb, const char *src, MOVDref *ref,

                         AVIOInterruptCB *int_cb, int use_absolute_path, AVFormatContext *fc)

{

    /* 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) {

        char filename[1024];

        const char *src_path;

        int i, l;



        /* find a source dir */

        src_path = strrchr(src, '/');

        if (src_path)

            src_path++;

        else

            src_path = src;



        /* find a next level down to target */

        for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--)

            if (ref->path[l] == '/') {

                if (i == ref->nlvl_to - 1)

                    break;

                else

                    i++;

            }



        /* compose filename if next level down to target was found */

        if (i == ref->nlvl_to - 1 && src_path - src  < sizeof(filename)) {

            memcpy(filename, src, src_path - src);

            filename[src_path - src] = 0;



            for (i = 1; i < ref->nlvl_from; i++)

                av_strlcat(filename, "../", sizeof(filename));



            av_strlcat(filename, ref->path + l + 1, sizeof(filename));



            if (!avio_open2(pb, filename, AVIO_FLAG_READ, int_cb, NULL))

                return 0;

        }

    } else if (use_absolute_path) {

        av_log(fc, AV_LOG_WARNING, "Using absolute path on user request, "

               "this is a possible security issue\n");

        if (!avio_open2(pb, ref->path, AVIO_FLAG_READ, int_cb, NULL))

            return 0;

    }



    return AVERROR(ENOENT);

}

static int mov_open_dref(AVIOContext **pb, const char *src, MOVDref *ref,

                         AVIOInterruptCB *int_cb, int use_absolute_path, AVFormatContext *fc)

{

    



    if (ref->nlvl_to > 0 && ref->nlvl_from > 0) {

        char filename[1024];

        const char *src_path;

        int i, l;



        

        src_path = strrchr(src, '/');

        if (src_path)

            src_path++;

        else

            src_path = src;



        

        for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--)

            if (ref->path[l] == '/') {

                if (i == ref->nlvl_to - 1)

                    break;

                else

                    i++;

            }



        

        if (i == ref->nlvl_to - 1 && src_path - src  < sizeof(filename)) {

            memcpy(filename, src, src_path - src);

            filename[src_path - src] = 0;



            for (i = 1; i < ref->nlvl_from; i++)

                av_strlcat(filename, "../", sizeof(filename));



            av_strlcat(filename, ref->path + l + 1, sizeof(filename));



            if (!avio_open2(pb, filename, AVIO_FLAG_READ, int_cb, NULL))

                return 0;

        }

    } else if (use_absolute_path) {

        av_log(fc, AV_LOG_WARNING, "Using absolute path on user request, "

               "this is a possible security issue\n");

        if (!avio_open2(pb, ref->path, AVIO_FLAG_READ, int_cb, NULL))

            return 0;

    }



    return AVERROR(ENOENT);

}

static int FUNC_0(AVIOContext **VAR_0, const char *VAR_1, MOVDref *VAR_2,

                         AVIOInterruptCB *VAR_3, int VAR_4, AVFormatContext *VAR_5)

{

    



    if (VAR_2->nlvl_to > 0 && VAR_2->nlvl_from > 0) {

        char VAR_6[1024];

        const char *VAR_7;

        int VAR_8, VAR_9;



        

        VAR_7 = strrchr(VAR_1, '/');

        if (VAR_7)

            VAR_7++;

        else

            VAR_7 = VAR_1;



        

        for (VAR_8 = 0, VAR_9 = strlen(VAR_2->path) - 1; VAR_9 >= 0; VAR_9--)

            if (VAR_2->path[VAR_9] == '/') {

                if (VAR_8 == VAR_2->nlvl_to - 1)

                    break;

                else

                    VAR_8++;

            }



        

        if (VAR_8 == VAR_2->nlvl_to - 1 && VAR_7 - VAR_1  < sizeof(VAR_6)) {

            memcpy(VAR_6, VAR_1, VAR_7 - VAR_1);

            VAR_6[VAR_7 - VAR_1] = 0;



            for (VAR_8 = 1; VAR_8 < VAR_2->nlvl_from; VAR_8++)

                av_strlcat(VAR_6, "../", sizeof(VAR_6));



            av_strlcat(VAR_6, VAR_2->path + VAR_9 + 1, sizeof(VAR_6));



            if (!avio_open2(VAR_0, VAR_6, AVIO_FLAG_READ, VAR_3, NULL))

                return 0;

        }

    } else if (VAR_4) {

        av_log(VAR_5, AV_LOG_WARNING, "Using absolute path on user request, "

               "this is a possible security issue\n");

        if (!avio_open2(VAR_0, VAR_2->path, AVIO_FLAG_READ, VAR_3, NULL))

            return 0;

    }



    return AVERROR(ENOENT);

}

static int FUNC_0(AVIOContext **VAR_0, const char *VAR_1, MOVDref *VAR_2,
AVIOInterruptCB *VAR_3, int VAR_4, AVFormatContext *VAR_5)
{ if (VAR_2->nlvl_to > 0 && VAR_2->nlvl_from > 0) { char VAR_6[1024]; const char *VAR_7; int VAR_8, VAR_9; VAR_7 = strrchr(VAR_1, '/'); if (VAR_7)
VAR_7++; else
VAR_7 = VAR_1; for (VAR_8 = 0, VAR_9 = strlen(VAR_2->path) - 1; VAR_9 >= 0; VAR_9--) if (VAR_2->path[VAR_9] == '/') { if (VAR_8 == VAR_2->nlvl_to - 1)
break; else
VAR_8++; } if (VAR_8 == VAR_2->nlvl_to - 1 && VAR_7 - VAR_1  < sizeof(VAR_6)) { memcpy(VAR_6, VAR_1, VAR_7 - VAR_1); VAR_6[VAR_7 - VAR_1] = 0; for (VAR_8 = 1; VAR_8 < VAR_2->nlvl_from; VAR_8++) av_strlcat(VAR_6, "../", sizeof(VAR_6)); av_strlcat(VAR_6, VAR_2->path + VAR_9 + 1, sizeof(VAR_6)); if (!avio_open2(VAR_0, VAR_6, AVIO_FLAG_READ, VAR_3, NULL))
return 0; } } else if (VAR_4) { av_log(VAR_5, AV_LOG_WARNING, "Using absolute path on user request, "
"this is a possible security issue\n"); if (!avio_open2(VAR_0, VAR_2->path, AVIO_FLAG_READ, VAR_3, NULL))
return 0; } return AVERROR(ENOENT); }