diff mbox series

[FFmpeg-devel,1/9] avformat/evcdec: ensure there are enough bytes to seekback

Message ID 20230620144042.9629-1-jamrial@gmail.com
State Accepted
Commit 2276bcc52acf224da38eadb8068a8535260678e0
Headers show
Series [FFmpeg-devel,1/9] avformat/evcdec: ensure there are enough bytes to seekback | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 fail Make fate failed

Commit Message

James Almer June 20, 2023, 2:40 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/evcdec.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

James Almer June 21, 2023, 4:31 p.m. UTC | #1
On 6/20/2023 11:40 AM, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   libavformat/evcdec.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
> index 890babd3cb..9c4969e78f 100644
> --- a/libavformat/evcdec.c
> +++ b/libavformat/evcdec.c
> @@ -30,6 +30,7 @@
>   
>   #include "rawdec.h"
>   #include "avformat.h"
> +#include "avio_internal.h"
>   #include "internal.h"
>   
>   
> @@ -192,8 +193,12 @@ static int evc_read_packet(AVFormatContext *s, AVPacket *pkt)
>       }
>   
>       while(!au_end_found) {
> -
>           uint8_t buf[EVC_NALU_LENGTH_PREFIX_SIZE];
> +
> +        ret = ffio_ensure_seekback(s->pb, EVC_NALU_LENGTH_PREFIX_SIZE);
> +        if (ret < 0)
> +            return ret;
> +
>           ret = avio_read(s->pb, (unsigned char *)&buf, EVC_NALU_LENGTH_PREFIX_SIZE);
>           if (ret < 0) {
>               av_packet_unref(pkt);

Will apply set.
diff mbox series

Patch

diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
index 890babd3cb..9c4969e78f 100644
--- a/libavformat/evcdec.c
+++ b/libavformat/evcdec.c
@@ -30,6 +30,7 @@ 
 
 #include "rawdec.h"
 #include "avformat.h"
+#include "avio_internal.h"
 #include "internal.h"
 
 
@@ -192,8 +193,12 @@  static int evc_read_packet(AVFormatContext *s, AVPacket *pkt)
     }
 
     while(!au_end_found) {
-
         uint8_t buf[EVC_NALU_LENGTH_PREFIX_SIZE];
+
+        ret = ffio_ensure_seekback(s->pb, EVC_NALU_LENGTH_PREFIX_SIZE);
+        if (ret < 0)
+            return ret;
+
         ret = avio_read(s->pb, (unsigned char *)&buf, EVC_NALU_LENGTH_PREFIX_SIZE);
         if (ret < 0) {
             av_packet_unref(pkt);