diff mbox series

[FFmpeg-devel,204/217] avcodec/ass_split: Don't presume strlen to be >= 2

Message ID 20201202042244.519127-70-andreas.rheinhardt@gmail.com
State Accepted
Commit f38f791a23a8acade7ea6554c80455dce7543dbd
Headers show
Series [FFmpeg-devel,01/45] avcodec/a64multienc: Fix memleak upon init failure | expand

Checks

Context Check Description
andriy/x86 warning Failed to apply patch

Commit Message

Andreas Rheinhardt Dec. 2, 2020, 4:22 a.m. UTC
Fixes potential heap-buffer-overflow.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/ass_split.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Rheinhardt April 2, 2021, 4:31 p.m. UTC | #1
On Wed, Dec 2, 2020 at 5:24 AM Andreas Rheinhardt <
andreas.rheinhardt@gmail.com> wrote:

> Fixes potential heap-buffer-overflow.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/ass_split.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
> index c2c388d9f0..189272bbd9 100644
> --- a/libavcodec/ass_split.c
> +++ b/libavcodec/ass_split.c
> @@ -376,7 +376,7 @@ ASSSplitContext *ff_ass_split(const char *buf)
>      ASSSplitContext *ctx = av_mallocz(sizeof(*ctx));
>      if (!ctx)
>          return NULL;
> -    if (buf && !memcmp(buf, "\xef\xbb\xbf", 3)) // Skip UTF-8 BOM header
> +    if (buf && !strncmp(buf, "\xef\xbb\xbf", 3)) // Skip UTF-8 BOM header
>          buf += 3;
>      ctx->current_section = -1;
>      if (ass_split(ctx, buf) < 0) {
> --
> 2.25.1
>
>
Will apply.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
index c2c388d9f0..189272bbd9 100644
--- a/libavcodec/ass_split.c
+++ b/libavcodec/ass_split.c
@@ -376,7 +376,7 @@  ASSSplitContext *ff_ass_split(const char *buf)
     ASSSplitContext *ctx = av_mallocz(sizeof(*ctx));
     if (!ctx)
         return NULL;
-    if (buf && !memcmp(buf, "\xef\xbb\xbf", 3)) // Skip UTF-8 BOM header
+    if (buf && !strncmp(buf, "\xef\xbb\xbf", 3)) // Skip UTF-8 BOM header
         buf += 3;
     ctx->current_section = -1;
     if (ass_split(ctx, buf) < 0) {