Re: [FFmpeg-devel] [PATCH] avformat/riffenc: correct calculation for extradata size

2020-07-25 Thread Gyan Doshi



On 25-07-2020 11:00 pm, Gyan Doshi wrote:

Will push in 12 hours.


Pushed as 93694fe777d12a9432b5ceeb564631da6311ae26
Gyan



On 25-07-2020 10:44 am, Gyan Doshi wrote:

In 1ec2b3de5a, the extradata size was affected when the raster was
signaled as flipped due to user-set option rather than via extradata.
This resulted in a wrong header size being written. Fixed.
---
  libavformat/riffenc.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index d0ee98bfcc..04a21fcffa 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -209,10 +209,10 @@ int ff_put_wav_header(AVFormatContext *s, 
AVIOContext *pb,

  void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par,
 int for_asf, int ignore_extradata, int 
rgb_frame_is_flipped)

  {
-    int keep_height = (par->extradata_size >= 9 &&
-  !memcmp(par->extradata + par->extradata_size - 
9, "BottomUp", 9)) ||

-  rgb_frame_is_flipped;
-    int extradata_size = par->extradata_size - 9*keep_height;
+    int flipped_extradata = (par->extradata_size >= 9 &&
+    !memcmp(par->extradata + 
par->extradata_size - 9, "BottomUp", 9));

+    int keep_height = flipped_extradata || rgb_frame_is_flipped;
+    int extradata_size = par->extradata_size - 9*flipped_extradata;
  enum AVPixelFormat pix_fmt = par->format;
  int pal_avi;


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/flvdec: Remove unnecessary initializations

2020-07-25 Thread Zhao Zhili
pre_tag_size is always reset by avio_rb32(). For AVFormatContext
start_time, as the document says, "NEVER set this value directly:
It is deduced from the AVStream values."
---
fix commit subject
 libavformat/flvdec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 08622739f3..31bdbbd5e9 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -747,7 +747,7 @@ static int flv_read_header(AVFormatContext *s)
 int flags;
 FLVContext *flv = s->priv_data;
 int offset;
-int pre_tag_size = 0;
+int pre_tag_size;
 
 /* Actual FLV data at 0xe4 in KUX file */
 if(!strcmp(s->iformat->name, "kux"))
@@ -773,7 +773,6 @@ static int flv_read_header(AVFormatContext *s)
 av_log(s, AV_LOG_WARNING, "Read FLV header error, input file is not a 
standard flv format, first PreviousTagSize0 always is 0\n");
 }
 
-s->start_time = 0;
 flv->sum_flv_tag_size = 0;
 flv->last_keyframe_stream_index = -1;
 
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/pgxdec: Fix invalid shift in write_frame_*

2020-07-25 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: left shift of negative value -121
> Fixes: 
> 23911/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGX_fuzzer-4986800258154496
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/pgxdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c
> index 93b9f4e7a0..e72ec84152 100644
> --- a/libavcodec/pgxdec.c
> +++ b/libavcodec/pgxdec.c
> @@ -102,7 +102,7 @@ error:
>  for (i = 0; i < height; i++) {   
>\
>  PIXEL *line = (PIXEL*)frame->data[0] + 
> i*frame->linesize[0]/sizeof(PIXEL);  \
>  for (j = 0; j < width; j++) {
>\
> -int val; 
>\
> +unsigned val;
> \

"unsigned" is longer than "int", so you need to delete a few spaces or
the '\' won't be in line with the others any more.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] Inconsistent handling of initial_padding and PTS adjustment

2020-07-25 Thread Kieran Kunhya
Hi,

I notice that some encoders adjust the PTS with initial_padding and some
don't.
Is this intentional and should we decide that all encoders should do this?

Regards,
Kieran Kunhya
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avcodec/mv30: Fix several integer overflows in idct_1d()

2020-07-25 Thread Michael Niedermayer
Fixes: signed integer overflow: -1846510390 + -361755993 cannot be represented 
in type 'int'
Fixes: 
23941/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MV30_fuzzer-5654696631730176

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/mv30.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c
index c83ba7ffbd..f9cc85f2ac 100644
--- a/libavcodec/mv30.c
+++ b/libavcodec/mv30.c
@@ -104,23 +104,23 @@ static void get_qtable(int16_t *table, int quant, const 
uint8_t *quant_tab)
 
 static inline void idct_1d(int *blk, int step)
 {
-const int t0 = blk[0 * step] + blk[4 * step];
-const int t1 = blk[0 * step] - blk[4 * step];
-const int t2 = blk[2 * step] + blk[6 * step];
-const int t3 = ((int)((blk[2 * step] - blk[6 * step]) * 362U) >> 8) - t2;
-const int t4 = t0 + t2;
-const int t5 = t0 - t2;
-const int t6 = t1 + t3;
-const int t7 = t1 - t3;
-const int t8 = blk[5 * step] + blk[3 * step];
-const int t9 = blk[5 * step] - blk[3 * step];
-const int tA = blk[1 * step] + blk[7 * step];
-const int tB = blk[1 * step] - blk[7 * step];
-const int tC = t8 + tA;
-const int tD = (int)((tB + t9) * 473U) >> 8;
-const int tE = (((int)(t9 * -669U) >> 8) - tC) + tD;
-const int tF = ((int)((tA - t8) * 362U) >> 8) - tE;
-const int t10 = (((int)(tB * 277U) >> 8) - tD) + tF;
+const unsigned t0 = blk[0 * step] + blk[4 * step];
+const unsigned t1 = blk[0 * step] - blk[4 * step];
+const unsigned t2 = blk[2 * step] + blk[6 * step];
+const unsigned t3 = ((int)((blk[2 * step] - blk[6 * step]) * 362U) >> 8) - 
t2;
+const unsigned t4 = t0 + t2;
+const unsigned t5 = t0 - t2;
+const unsigned t6 = t1 + t3;
+const unsigned t7 = t1 - t3;
+const unsigned t8 = blk[5 * step] + blk[3 * step];
+const unsigned t9 = blk[5 * step] - blk[3 * step];
+const unsigned tA = blk[1 * step] + blk[7 * step];
+const unsigned tB = blk[1 * step] - blk[7 * step];
+const unsigned tC = t8 + tA;
+const unsigned tD = (int)((tB + t9) * 473U) >> 8;
+const unsigned tE = (((int)(t9 * -669U) >> 8) - tC) + tD;
+const unsigned tF = ((int)((tA - t8) * 362U) >> 8) - tE;
+const unsigned t10 = (((int)(tB * 277U) >> 8) - tD) + tF;
 
 blk[0 * step] = t4 + tC;
 blk[1 * step] = t6 + tE;
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] avcodec/pgxdec: Fix invalid shift in write_frame_*

2020-07-25 Thread Michael Niedermayer
Fixes: left shift of negative value -121
Fixes: 
23911/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGX_fuzzer-4986800258154496

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/pgxdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c
index 93b9f4e7a0..e72ec84152 100644
--- a/libavcodec/pgxdec.c
+++ b/libavcodec/pgxdec.c
@@ -102,7 +102,7 @@ error:
 for (i = 0; i < height; i++) { 
 \
 PIXEL *line = (PIXEL*)frame->data[0] + 
i*frame->linesize[0]/sizeof(PIXEL);  \
 for (j = 0; j < width; j++) {  
 \
-int val;   
 \
+unsigned val;  
  \
 if (sign)  
 \
 val = (PIXEL)bytestream2_get_ ##suffix(g) + (1 << (depth - 
1)); \
 else   
 \
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] working with file descriptors on Android

2020-07-25 Thread Matthieu Bouron
On Wed, Jul 22, 2020 at 2:38 PM Alex Cohn  wrote:

> Usually, we employ the `pipe:` protocol to deal with the numerical
> file descriptors, and this answers all our needs. On Android, there is
> a different use case in which numerical file descriptors appear, and
> this is not covered well with `pipe:` protocol.
>
> This happens when a file is opened in scoped storage
> (https://developer.android.com/training/data-storage#scoped-storage).
> Currently, there is an exception that still allows `stdio.h` - based
> access to the media files
> (
> https://developer.android.com/preview/privacy/storage#media-files-raw-paths
> ),
> but the document says that it may be slow (we still cannot have true
> evidence since Android 11 is not released yet), and anyways the clean
> way to access media files on what is known as 'external storage' is
> through a document picker Intent
> (
> https://developer.android.com/reference/android/content/Intent#ACTION_OPEN_DOCUMENT
> and
> https://developer.android.com/reference/android/content/Intent#ACTION_CREATE_DOCUMENT
> ).
>
> The Intent produces a `content://` URI from which a DocumentProvider
> can produce an integer file descriptor. This descriptor can be passed
> to ffmpeg via pipe: protocol, and almost works, except for a few
> glitches.
>
>  1. This fd must be closed after use. Pipe is not closeable.
>
>  2. This fd is seekable, and therefore can be used to work with `.mp4`
> or some other file formats that don't work through pipe protocol.
>
>  3. We can find the actual file name extension for this fd, to
> facilitate `av_guess_format()` both for input and for output.
>
> I have recently prepared two approaches to face this issue. One is an
> easy patch for the `file:` protocol that recognizes the `/proc/self/`
> prefix and uses the number as fd. This relies heavily on Java (or
> Kotlin) processing of the results of document picker. The other way
> adds a `content://` protocol and does all heavy lifting (calling
> system Java API through JNI) itself.
>

Hi,

I already submitted a patch for the second approach in 2015-2016
(while submitting JNI support + MediaCodec). This approach was
rejected because the project did not want to have jni support in
libavutils but instead have it scoped to libavcodec with the decoder.

Original thread:
https://ffmpeg.org/pipermail/ffmpeg-devel/2015-October/180593.html
The patch:
https://www.mail-archive.com/ffmpeg-devel@ffmpeg.org/msg29451.html

I use this patch in production at work (which contains a hack to import jni
support to libavformat):
https://github.com/Stupeflix/FFmpeg/commit/6d06b14939cb05e8a377d2ba14ed689b361f0303

I don't know if the project has changed his mind regarding the java/jni
stuff but I'd also like to upstream this feature (I think content uri
support
is a nice and useful feature for the Android platform).

Best regards,
Matthieu
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/ape: Remove seektable and bittable

2020-07-25 Thread Michael Niedermayer
Suggested-by: Andreas
Signed-off-by: Michael Niedermayer 
---
 libavformat/ape.c | 75 ---
 1 file changed, 25 insertions(+), 50 deletions(-)

diff --git a/libavformat/ape.c b/libavformat/ape.c
index d92cb2867d..2698c770ee 100644
--- a/libavformat/ape.c
+++ b/libavformat/ape.c
@@ -77,10 +77,6 @@ typedef struct APEContext {
 uint16_t bps;
 uint16_t channels;
 uint32_t samplerate;
-
-/* Seektable */
-uint32_t *seektable;
-uint8_t  *bittable;
 } APEContext;
 
 static int ape_read_close(AVFormatContext * s);
@@ -130,20 +126,6 @@ static void ape_dumpinfo(AVFormatContext * s, APEContext * 
ape_ctx)
 av_log(s, AV_LOG_DEBUG, "\nSeektable\n\n");
 if ((ape_ctx->seektablelength / sizeof(uint32_t)) != ape_ctx->totalframes) 
{
 av_log(s, AV_LOG_DEBUG, "No seektable\n");
-} else {
-for (i = 0; i < ape_ctx->seektablelength / sizeof(uint32_t); i++) {
-if (i < ape_ctx->totalframes - 1) {
-av_log(s, AV_LOG_DEBUG, "%8d   %"PRIu32" (%"PRIu32" bytes)",
-   i, ape_ctx->seektable[i],
-   ape_ctx->seektable[i + 1] - ape_ctx->seektable[i]);
-if (ape_ctx->bittable)
-av_log(s, AV_LOG_DEBUG, " + %2d bits\n",
-   ape_ctx->bittable[i]);
-av_log(s, AV_LOG_DEBUG, "\n");
-} else {
-av_log(s, AV_LOG_DEBUG, "%8d   %"PRIu32"\n", i, 
ape_ctx->seektable[i]);
-}
-}
 }
 
 av_log(s, AV_LOG_DEBUG, "\nFrames\n\n");
@@ -262,10 +244,10 @@ static int ape_read_header(AVFormatContext * s)
ape->totalframes);
 return AVERROR_INVALIDDATA;
 }
-if (ape->seektablelength / sizeof(*ape->seektable) < ape->totalframes) {
+if (ape->seektablelength / sizeof(uint32_t) < ape->totalframes) {
 av_log(s, AV_LOG_ERROR,
"Number of seek entries is less than number of frames: 
%"SIZE_SPECIFIER" vs. %"PRIu32"\n",
-   ape->seektablelength / sizeof(*ape->seektable), 
ape->totalframes);
+   ape->seektablelength / sizeof(uint32_t), ape->totalframes);
 return AVERROR_INVALIDDATA;
 }
 ape->frames   = av_malloc_array(ape->totalframes, sizeof(APEFrame));
@@ -281,39 +263,26 @@ static int ape_read_header(AVFormatContext * s)
 if (ape->totalframes > 1)
 ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1);
 
-if (ape->seektablelength > 0) {
-ape->seektable = av_mallocz(ape->seektablelength);
-if (!ape->seektable) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-for (i = 0; i < ape->seektablelength / sizeof(uint32_t) && 
!pb->eof_reached; i++)
-ape->seektable[i] = avio_rl32(pb);
-if (ape->fileversion < 3810) {
-ape->bittable = av_mallocz(ape->totalframes);
-if (!ape->bittable) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
-for (i = 0; i < ape->totalframes && !pb->eof_reached; i++)
-ape->bittable[i] = avio_r8(pb);
-}
-if (pb->eof_reached) {
-av_log(s, AV_LOG_ERROR, "File truncated\n");
-ret = AVERROR_INVALIDDATA;
-goto fail;
-}
-}
-
 ape->frames[0].pos = ape->firstframe;
 ape->frames[0].nblocks = ape->blocksperframe;
 ape->frames[0].skip= 0;
+avio_rl32(pb); // seektable[0]
 for (i = 1; i < ape->totalframes; i++) {
-ape->frames[i].pos  = ape->seektable[i] + ape->junklength;
+uint32_t seektable_entry = avio_rl32(pb);
+ape->frames[i].pos  = seektable_entry + ape->junklength;
 ape->frames[i].nblocks  = ape->blocksperframe;
 ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos;
 ape->frames[i].skip = (ape->frames[i].pos - ape->frames[0].pos) & 
3;
+
+if (pb->eof_reached) {
+av_log(s, AV_LOG_ERROR, "seektable truncated\n");
+ret = AVERROR_INVALIDDATA;
+goto fail;
+}
+ff_dlog(s, "seektable: %8d   %"PRIu32"\n", i, seektable_entry);
 }
+avio_skip(pb, ape->seektablelength / sizeof(uint32_t) - ape->totalframes);
+
 ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks;
 /* calculate final packet size from total file size, if available */
 file_size = avio_size(pb);
@@ -335,10 +304,18 @@ static int ape_read_header(AVFormatContext * s)
 }
 if (ape->fileversion < 3810) {
 for (i = 0; i < ape->totalframes; i++) {
-if (i < ape->totalframes - 1 && ape->bittable[i + 1])
-ape->frames[i].size += 4;
+int bits = avio_r8(pb);
+if (i && bits)
+ape->frames[i - 1].size += 4;
+
 ape->frames[i].skip <<= 3;
-ape->frames[i].skip  += ape->bittable[i];
+

Re: [FFmpeg-devel] [PATCH] avformat/ape: Error out in case of EOF in the header

2020-07-25 Thread Michael Niedermayer
On Sat, Jul 25, 2020 at 06:10:44AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: OOM
> > Fixes: 
> > 24375/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6216862443241472
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/ape.c | 8 +---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/libavformat/ape.c b/libavformat/ape.c
> > index 39a584aa98..e966063ad7 100644
> > --- a/libavformat/ape.c
> > +++ b/libavformat/ape.c
> > @@ -253,7 +253,7 @@ static int ape_read_header(AVFormatContext * s)
> >  avio_skip(pb, ape->wavheaderlength);
> >  }
> >  
> > -if(!ape->totalframes){
> > +if(!ape->totalframes || pb->eof_reached){
> >  av_log(s, AV_LOG_ERROR, "No frames in the file!\n");
> >  return AVERROR(EINVAL);
> >  }
> > @@ -298,8 +298,10 @@ static int ape_read_header(AVFormatContext * s)
> >  for (i = 0; i < ape->totalframes && !pb->eof_reached; i++)
> >  ape->bittable[i] = avio_r8(pb);
> >  }
> > -if (pb->eof_reached)
> > -av_log(s, AV_LOG_WARNING, "File truncated\n");
> > +if (pb->eof_reached) {
> > +av_log(s, AV_LOG_ERROR, "File truncated\n");
> > +return AVERROR_INVALIDDATA;
> > +}
> 
> The above will lead to a memleak as long as cleaning up on read_header
> failure is not automatic. Furthermore, it's the first of the checks that
> fixes the OOM scenario, not the second, isn't it?

yes, will apply with the leak issue fixed


> 
> - Andreas
> 
> PS: One could remove the allocations for seek- and bittable altogether;
> only ape_dumpinfo() needs to have the seektable, the bittable as well as
> the frames at the same time.

will post a patch doing that

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/riffenc: correct calculation for extradata size

2020-07-25 Thread Gyan Doshi

Will push in 12 hours.

On 25-07-2020 10:44 am, Gyan Doshi wrote:

In 1ec2b3de5a, the extradata size was affected when the raster was
signaled as flipped due to user-set option rather than via extradata.
This resulted in a wrong header size being written. Fixed.
---
  libavformat/riffenc.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index d0ee98bfcc..04a21fcffa 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -209,10 +209,10 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
  void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par,
 int for_asf, int ignore_extradata, int 
rgb_frame_is_flipped)
  {
-int keep_height = (par->extradata_size >= 9 &&
-  !memcmp(par->extradata + par->extradata_size - 9, 
"BottomUp", 9)) ||
-  rgb_frame_is_flipped;
-int extradata_size = par->extradata_size - 9*keep_height;
+int flipped_extradata = (par->extradata_size >= 9 &&
+!memcmp(par->extradata + par->extradata_size - 9, 
"BottomUp", 9));
+int keep_height = flipped_extradata || rgb_frame_is_flipped;
+int extradata_size = par->extradata_size - 9*flipped_extradata;
  enum AVPixelFormat pix_fmt = par->format;
  int pal_avi;
  


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] cineform decoder bug

2020-07-25 Thread Paul B Mahol
Hi,

In decoder bits per raw sample is always hardcoded to 10, that is not correct.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavf/srt: fix build fail when used the libsrt 1.4.1

2020-07-25 Thread Christopher Degawa
On Sat, Jul 18, 2020 at 9:24 AM myp...@gmail.com  wrote:
>
> On Thu, Jul 16, 2020 at 9:35 AM myp...@gmail.com  wrote:
> >
> > On Tue, Jul 14, 2020 at 9:47 PM Moritz Barsnick  wrote:
> > >
> > > On Sun, Jul 12, 2020 at 22:44:46 +0800, myp...@gmail.com wrote:
> > > > Maybe I give an inaccurate description in the commit message, in fact,
> > > > libsrt 1.4.1 remove the SRTO_STRICTENC/SRTO_SMOOTHER option, it's will
> > > > lead to FFmpeg build fail when using libsrt  version >= 1.4.1
> > >
> > > I don't mind you description. Yet your code change references 1.4.1:
> > > SRT_VERSION_VALUE >= 0x010401
> > > while I am trying to make the point that 1.4.0 also needs this change
> > > (or 1.3.0 in one case, which is already ensured by #if).
> > >
> >
> > After double-check, I think the patch is Ok, in fact, libsrt keeps the
> > deprecated SRTO_STRICTENC/SRTO_SMOOTHER options in srt.h (inclued the
> > options in libsrt 1.3.3/1.3.4/1.4.0) until commit
> > 0e2201aff6b379979cec43fee5e8f162717f6346 , so FFmpeg build with libsrt
> > 1.3.3/1.3.4/1.4.0 is OK with the patch.
> Ping
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Ping
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] flvdec: Remove unnecessary initializations

2020-07-25 Thread Zhao Zhili
pre_tag_size is always reset by avio_rb32(). For AVFormatContext
start_time, as the document says, "NEVER set this value directly:
It is deduced from the AVStream values."
---
 libavformat/flvdec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 08622739f3..31bdbbd5e9 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -747,7 +747,7 @@ static int flv_read_header(AVFormatContext *s)
 int flags;
 FLVContext *flv = s->priv_data;
 int offset;
-int pre_tag_size = 0;
+int pre_tag_size;
 
 /* Actual FLV data at 0xe4 in KUX file */
 if(!strcmp(s->iformat->name, "kux"))
@@ -773,7 +773,6 @@ static int flv_read_header(AVFormatContext *s)
 av_log(s, AV_LOG_WARNING, "Read FLV header error, input file is not a 
standard flv format, first PreviousTagSize0 always is 0\n");
 }
 
-s->start_time = 0;
 flv->sum_flv_tag_size = 0;
 flv->last_keyframe_stream_index = -1;
 
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5] libavcodec/jpeg2000dec: Support for PPM marker

2020-07-25 Thread gautamramk
From: Gautam Ramakrishnan 

This patch adds support for PPM marker for JPEG2000
decoder. It allows the samples p1_03.j2k and p1_05.j2k
to be decoded.
---
 libavcodec/jpeg2000dec.c | 106 +++
 1 file changed, 96 insertions(+), 10 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index a470cf47da..9cc416f66b 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -71,6 +71,7 @@ typedef struct Jpeg2000POC {
 typedef struct Jpeg2000TilePart {
 uint8_t tile_index; // Tile index who refers the tile-part
 const uint8_t *tp_end;
+GetByteContext header_tpg;  // bit stream of header if PPM header 
is used
 GetByteContext tpg; // bit stream in tile-part
 } Jpeg2000TilePart;
 
@@ -102,7 +103,13 @@ typedef struct Jpeg2000DecoderContext {
 uint8_t cbps[4];// bits per sample in particular components
 uint8_t sgnd[4];// if a component is signed
 uint8_t properties[4];
+
+uint8_t has_ppm;
+uint8_t *packed_headers; // contains packed headers. Used only 
along with PPM marker
+int packed_headers_size;
+GetByteContext  packed_headers_stream;
 uint8_t in_tile_headers;
+
 int cdx[4], cdy[4];
 int precision;
 int ncomponents;
@@ -929,6 +936,30 @@ static int get_plt(Jpeg2000DecoderContext *s, int n)
 return 0;
 }
 
+static int get_ppm(Jpeg2000DecoderContext *s, int n)
+{
+void *new;
+
+if (n < 3) {
+av_log(s->avctx, AV_LOG_ERROR, "Invalid length for PPM data.\n");
+return AVERROR_INVALIDDATA;
+}
+bytestream2_get_byte(>g); //Zppm is skipped and not used
+new = av_realloc(s->packed_headers,
+ s->packed_headers_size + n - 3);
+if (new) {
+s->packed_headers = new;
+} else
+return AVERROR(ENOMEM);
+s->has_ppm = 1;
+memset(>packed_headers_stream, 0, sizeof(s->packed_headers_stream));
+bytestream_get_buffer(>g.buffer, s->packed_headers + 
s->packed_headers_size,
+  n - 3);
+s->packed_headers_size += n - 3;
+
+return 0;
+}
+
 static int get_ppt(Jpeg2000DecoderContext *s, int n)
 {
 Jpeg2000Tile *tile;
@@ -1040,8 +1071,19 @@ static int getlblockinc(Jpeg2000DecoderContext *s)
 return res;
 }
 
-static inline void select_stream(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
+static inline void select_header(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
  int *tp_index)
+{
+s->g = tile->tile_part[*tp_index].header_tpg;
+if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
+if (*tp_index < FF_ARRAY_ELEMS(tile->tile_part) - 1) {
+s->g = tile->tile_part[++(*tp_index)].tpg;
+}
+}
+}
+
+static inline void select_stream(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
+ int *tp_index, Jpeg2000CodingStyle *codsty)
 {
 s->g = tile->tile_part[*tp_index].tpg;
 if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) {
@@ -1049,8 +1091,12 @@ static inline void select_stream(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 s->g = tile->tile_part[++(*tp_index)].tpg;
 }
 }
-if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
-bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
+if (codsty->csty & JPEG2000_CSTY_SOP) {
+if (bytestream2_peek_be32(>g) == JPEG2000_SOP_FIXED_BYTES)
+bytestream2_skip(>g, JPEG2000_SOP_BYTE_LENGTH);
+else
+av_log(s->avctx, AV_LOG_ERROR, "SOP marker not found. instead 
%X\n", bytestream2_peek_be32(>g));
+}
 }
 
 static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile 
*tile, int *tp_index,
@@ -1065,10 +,12 @@ static int 
jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile,
 return 0;
 rlevel->band[0].prec[precno].decoded_layers = layno + 1;
 // Select stream to read from
-if (tile->has_ppt)
+if (s->has_ppm)
+select_header(s, tile, tp_index);
+else if (tile->has_ppt)
 s->g = tile->packed_headers_stream;
 else
-select_stream(s, tile, tp_index);
+select_stream(s, tile, tp_index, codsty);
 
 if (!(ret = get_bits(s, 1))) {
 jpeg2000_flush(s);
@@ -1179,9 +1227,12 @@ static int jpeg2000_decode_packet(Jpeg2000DecoderContext 
*s, Jpeg2000Tile *tile,
 }
 
 // Save state of stream
-if (tile->has_ppt) {
+if (s->has_ppm) {
+tile->tile_part[*tp_index].header_tpg = s->g;
+select_stream(s, tile, tp_index, codsty);
+} else if (tile->has_ppt) {
 tile->packed_headers_stream = s->g;
-select_stream(s, tile, tp_index);
+select_stream(s, tile, tp_index, codsty);
 }
 for (bandno = 0; bandno < rlevel->nbands; bandno++) {
 Jpeg2000Band *band = 

[FFmpeg-devel] AVWriter again (was: v2 1/2] avformat/url: check double dot is not to parent directory)

2020-07-25 Thread Nicolas George
Marton Balint (12020-07-25):
> And I also would like to point out that using static strings with
> MAX_URL_SIZE is not OK. This function supports an arbitrary buffer size, so
> limiting it to MAX_URL_SIZE is a bug.

Excellent point. That would require changing the prototype of a few
functions, but they are internal, we can do it.

For this, I would like to pitch the AVWriter API once again, because it
is made precisely for these cases: when you need to return a string of
arbitrary length, but would like to avoid, as much a possible, the
overhead of dynamically allocating it and the many error tests that come
with it. It is like AVBPrint, but better.

Let me elaborate without polluting the discussion by showing the actual
implementation.

So, let us say that function A calls function B, and function B needs to
return a string of arbitrary length but often small (I say string, but
the API can deal with binary data).

Likely use cases: rewriting an URL like here; escaping special
characters; serialization to key=value string; serialization to JSON or
XML; character encoding conversion, zlib-style unpacking, etc.


First, from the point of view of B, the function that needs to return
the string:

Instead of either:

int B(char *buf, size_t buf_size, other arguments);
int B(char **buf, other arguments);

request an AVWriter as argument:

void B(AVWriter wr, other arguments);

Then, just write in it with the various API functions:
av_writer_write(), av_writer_printf(), etc.

And that's all. Everything is taken care of: the string will grow as
needed, the size will be tracked, error checks are made. Nothing to
worry about at all.


Now, from the point of view of A, the function that calls B and gets a
string in return:

Instead of declaring a buffer, or a pointer to a buffer, declare:

AVWriter wr = av_dynbuf_writer();

and call B with it: B(wr, ...).

Then, extract the string, check for error (of course: dynamic allocation
can happen and fail; but this error check is the only one necessary),
use the string and free it:

char *msg = av_dynbuf_writer_get_data(wr, NULL);
if (!msg)
return AVERROR(ENOMEM);
do something with msg
av_dynbuf_writer_reset(wr);

I concede, for this example, av_dynbuf_writer_get_data() is one more
step than using the pointer directly. But as soon as the code becomes
more complex, in particular as soon as it uses the same writer twice to
put two strings together, this extra step is balanced by the fewer error
checks necessary.


All said, it makes one more API to learn, but IMHO, it is very simple to
learn: seven line of sample code. And the benefits are immediate.

Plus: there are many wonderful features that I have not told you about
yet.

So, Steven, Marton and the others: presented like that, does it look
appealing? Shall I elaborate?

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/url: check double dot is not to parent directory

2020-07-25 Thread Steven Liu
Marton Balint  于2020年7月25日周六 下午5:40写道:

> And I also would like to point out that using static strings with
> MAX_URL_SIZE is not OK. This function supports an arbitrary buffer size,
> so limiting it to MAX_URL_SIZE is a bug.
Okay, get it, i'm reworking.

Thanks
Steven
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/url: check double dot is not to parent directory

2020-07-25 Thread Marton Balint



On Sat, 25 Jul 2020, Zlomek, Josef wrote:


Hi Steven,

It is better but still not correct. Consider this test:

test("http://server/foo/bar;,
"a/b/../c/d/../e../.../..f/g../h../other/url/a.mp3/...");
It should give "
http://server/foo/bar/a/c/e../.../..f/g../h../other/url/a.mp3/...;.

I think the best would be to use strtok(p, "/") to split the path into the
components and for each ".." component remove the previous one (if there
are some still).


And I also would like to point out that using static strings with 
MAX_URL_SIZE is not OK. This function supports an arbitrary buffer size, 
so limiting it to MAX_URL_SIZE is a bug.


Regards,
Marton



Best regards,
Josef

On Sat, Jul 25, 2020 at 4:45 AM Steven Liu  wrote:


fix ticket: 8814
if get ".." in the url, check next byte and lead byte by double dot,
it there have no '/' and not root node, it is not used go to directory ".."

Signed-off-by: Steven Liu 
---
 libavformat/url.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavformat/url.c b/libavformat/url.c
index 20463a6674..35f27fe3ca 100644
--- a/libavformat/url.c
+++ b/libavformat/url.c
@@ -97,6 +97,18 @@ static void trim_double_dot_url(char *buf, const char
*rel, int size)
 /* set new current position if the root node is changed */
 p = root;
 while (p && (node = strstr(p, ".."))) {
+if (strlen(node) > 2 && node[2] != '/') {
+node = strstr(node + 1, "..");
+if (!node)
+break;
+}
+
+if (p != node && p[node - p - 1] != '/') {
+node = strstr(node + 1, "..");
+if (!node)
+break;
+}
+
 av_strlcat(tmp_path, p, node - p + strlen(tmp_path));
 p = node + 3;
 sep = strrchr(tmp_path, '/');
--
2.25.0




___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".




--
Josef Zlomek
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/url: check double dot is not to parent directory

2020-07-25 Thread Steven Liu
Nicolas George  于2020年7月25日周六 下午4:44写道:
>
> Steven Liu (12020-07-25):
> > > And I think you would better rework the complete logic of the test:
> > agreed, I think need lots of testcase for the logic, ../ .../..
> > dummy../... .../..dummy and so on,
> > maybe need spend some time to do it :D
>
> I did not mean the FATE test for this feature, I meant the test of
> whether something is a parent directory or not. It should parse the
Yes, I mean, not only same as your suggestion, also need make full FATE.
> path, not fish for a pattern.
>
> Regards,
>
> --
>   Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/url: check double dot is not to parent directory

2020-07-25 Thread Nicolas George
Steven Liu (12020-07-25):
> > And I think you would better rework the complete logic of the test:
> agreed, I think need lots of testcase for the logic, ../ .../..
> dummy../... .../..dummy and so on,
> maybe need spend some time to do it :D

I did not mean the FATE test for this feature, I meant the test of
whether something is a parent directory or not. It should parse the
path, not fish for a pattern.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/url: check double dot is not to parent directory

2020-07-25 Thread Steven Liu
Nicolas George  于2020年7月25日周六 下午4:31写道:
>
> Steven Liu (12020-07-25):
> > fix ticket: 8814
> > if get ".." in the url, check next byte and lead byte by double dot,
> > it there have no '/' and not root node, it is not used go to directory ".."
> >
> > Signed-off-by: Steven Liu 
> > ---
> >  libavformat/url.c | 12 
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/libavformat/url.c b/libavformat/url.c
> > index 20463a6674..35f27fe3ca 100644
> > --- a/libavformat/url.c
> > +++ b/libavformat/url.c
> > @@ -97,6 +97,18 @@ static void trim_double_dot_url(char *buf, const char 
> > *rel, int size)
> >  /* set new current position if the root node is changed */
> >  p = root;
> >  while (p && (node = strstr(p, ".."))) {
>
> > +if (strlen(node) > 2 && node[2] != '/') {
>
> I have not yet looked at the whole patch, but this strlen() test is
> useless.
>
> And I think you would better rework the complete logic of the test:
agreed, I think need lots of testcase for the logic, ../ .../..
dummy../... .../..dummy and so on,
maybe need spend some time to do it :D
> strstring ".." is a broken method.
>
> > +node = strstr(node + 1, "..");
> > +if (!node)
> > +break;
> > +}
> > +
> > +if (p != node && p[node - p - 1] != '/') {
> > +node = strstr(node + 1, "..");
> > +if (!node)
> > +break;
> > +}
> > +
> >  av_strlcat(tmp_path, p, node - p + strlen(tmp_path));
> >  p = node + 3;
> >  sep = strrchr(tmp_path, '/');
>
> Regards,
>
> --
>   Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/url: check double dot is not to parent directory

2020-07-25 Thread Nicolas George
刘歧 (12020-07-25):
> I think the best would be to use strtok(p, "/") to split the path into the
> components and for each ".." component remove the previous one (if there
> are some still).
> I think you can submit patch if you have full idea for it.

strtok() is a terrible API, and better not used, but you are right, the
logic of the parsing is flawed.

I would suggest to keep walk from / to / (using strchr() probably), and
keep a pointer on the last two in the source and the last one in the
target IIRC.

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/url: check double dot is not to parent directory

2020-07-25 Thread Nicolas George
Steven Liu (12020-07-25):
> fix ticket: 8814
> if get ".." in the url, check next byte and lead byte by double dot,
> it there have no '/' and not root node, it is not used go to directory ".."
> 
> Signed-off-by: Steven Liu 
> ---
>  libavformat/url.c | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/libavformat/url.c b/libavformat/url.c
> index 20463a6674..35f27fe3ca 100644
> --- a/libavformat/url.c
> +++ b/libavformat/url.c
> @@ -97,6 +97,18 @@ static void trim_double_dot_url(char *buf, const char 
> *rel, int size)
>  /* set new current position if the root node is changed */
>  p = root;
>  while (p && (node = strstr(p, ".."))) {

> +if (strlen(node) > 2 && node[2] != '/') {

I have not yet looked at the whole patch, but this strlen() test is
useless.

And I think you would better rework the complete logic of the test:
strstring ".." is a broken method.

> +node = strstr(node + 1, "..");
> +if (!node)
> +break;
> +}
> +
> +if (p != node && p[node - p - 1] != '/') {
> +node = strstr(node + 1, "..");
> +if (!node)
> +break;
> +}
> +
>  av_strlcat(tmp_path, p, node - p + strlen(tmp_path));
>  p = node + 3;
>  sep = strrchr(tmp_path, '/');

Regards,

-- 
  Nicolas George


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/url: check double dot is not to parent directory

2020-07-25 Thread 刘歧


在 2020/7/25 下午2:11,“ffmpeg-devel 代表 Zlomek, 
Josef” 写入:

Hi Steven,

It is better but still not correct. Consider this test:

test("http://server/foo/bar;,
"a/b/../c/d/../e../.../..f/g../h../other/url/a.mp3/...");
It should give "
http://server/foo/bar/a/c/e../.../..f/g../h../other/url/a.mp3/...;.

I think the best would be to use strtok(p, "/") to split the path into the
components and for each ".." component remove the previous one (if there
are some still).
I think you can submit patch if you have full idea for it.

Best regards,
Josef

On Sat, Jul 25, 2020 at 4:45 AM Steven Liu  wrote:

> fix ticket: 8814
> if get ".." in the url, check next byte and lead byte by double dot,
> it there have no '/' and not root node, it is not used go to directory 
".."
>
> Signed-off-by: Steven Liu 
> ---
>  libavformat/url.c | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/libavformat/url.c b/libavformat/url.c
> index 20463a6674..35f27fe3ca 100644
> --- a/libavformat/url.c
> +++ b/libavformat/url.c
> @@ -97,6 +97,18 @@ static void trim_double_dot_url(char *buf, const char
> *rel, int size)
>  /* set new current position if the root node is changed */
>  p = root;
>  while (p && (node = strstr(p, ".."))) {
> +if (strlen(node) > 2 && node[2] != '/') {
> +node = strstr(node + 1, "..");
> +if (!node)
> +break;
> +}
> +
> +if (p != node && p[node - p - 1] != '/') {
> +node = strstr(node + 1, "..");
> +if (!node)
> +break;
> +}
> +
>  av_strlcat(tmp_path, p, node - p + strlen(tmp_path));
>  p = node + 3;
>  sep = strrchr(tmp_path, '/');
> --
> 2.25.0
>
>
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



-- 
Josef Zlomek
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".




___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/url: check double dot is not to parent directory

2020-07-25 Thread Zlomek, Josef
Hi Steven,

It is better but still not correct. Consider this test:

test("http://server/foo/bar;,
"a/b/../c/d/../e../.../..f/g../h../other/url/a.mp3/...");
It should give "
http://server/foo/bar/a/c/e../.../..f/g../h../other/url/a.mp3/...;.

I think the best would be to use strtok(p, "/") to split the path into the
components and for each ".." component remove the previous one (if there
are some still).

Best regards,
Josef

On Sat, Jul 25, 2020 at 4:45 AM Steven Liu  wrote:

> fix ticket: 8814
> if get ".." in the url, check next byte and lead byte by double dot,
> it there have no '/' and not root node, it is not used go to directory ".."
>
> Signed-off-by: Steven Liu 
> ---
>  libavformat/url.c | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/libavformat/url.c b/libavformat/url.c
> index 20463a6674..35f27fe3ca 100644
> --- a/libavformat/url.c
> +++ b/libavformat/url.c
> @@ -97,6 +97,18 @@ static void trim_double_dot_url(char *buf, const char
> *rel, int size)
>  /* set new current position if the root node is changed */
>  p = root;
>  while (p && (node = strstr(p, ".."))) {
> +if (strlen(node) > 2 && node[2] != '/') {
> +node = strstr(node + 1, "..");
> +if (!node)
> +break;
> +}
> +
> +if (p != node && p[node - p - 1] != '/') {
> +node = strstr(node + 1, "..");
> +if (!node)
> +break;
> +}
> +
>  av_strlcat(tmp_path, p, node - p + strlen(tmp_path));
>  p = node + 3;
>  sep = strrchr(tmp_path, '/');
> --
> 2.25.0
>
>
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



-- 
Josef Zlomek
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".