diff mbox series

[FFmpeg-devel,1/6] avcodec/movtextenc: Fix infinite loop due to variable truncation

Message ID AM7PR03MB6660BBF1F4FDFA989E4618F18F679@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit bb89a2f64fd1d74cc51af62d5ef133be274dd7af
Headers show
Series [FFmpeg-devel,1/6] avcodec/movtextenc: Fix infinite loop due to variable truncation
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 30, 2021, 10:49 a.m. UTC
Regression since af043b839c38e850af1184fd6be691f8475c048e.
Fixes ticket #9409.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/movtextenc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Philip Langdale Dec. 2, 2021, 3:27 a.m. UTC | #1
On Tue, 30 Nov 2021 11:49:26 +0100
Andreas Rheinhardt <andreas.rheinhardt@outlook.com> wrote:

> Regression since af043b839c38e850af1184fd6be691f8475c048e.
> Fixes ticket #9409.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/movtextenc.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
> index 2ae5a9bf0b..0632463a63 100644
> --- a/libavcodec/movtextenc.c
> +++ b/libavcodec/movtextenc.c
> @@ -84,7 +84,7 @@ typedef struct {
>      uint8_t box_flags;
>      StyleBox d;
>      uint16_t text_pos;
> -    uint16_t byte_count;
> +    unsigned byte_count;
>      char **fonts;
>      int font_count;
>      double font_scale_factor;
> @@ -584,9 +584,9 @@ static void mov_text_cancel_overrides_cb(void
> *priv, const char *style_name) mov_text_ass_style_set(s, style);
>  }
>  
> -static uint16_t utf8_strlen(const char *text, int len)
> +static unsigned utf8_strlen(const char *text, int len)
>  {
> -    uint16_t i = 0, ret = 0;
> +    unsigned i = 0, ret = 0;
>      while (i < len) {
>          char c = text[i];
>          if ((c & 0x80) == 0)
> @@ -606,7 +606,7 @@ static uint16_t utf8_strlen(const char *text, int
> len) 
>  static void mov_text_text_cb(void *priv, const char *text, int len)
>  {
> -    uint16_t utf8_len = utf8_strlen(text, len);
> +    unsigned utf8_len = utf8_strlen(text, len);
>      MovTextContext *s = priv;
>      av_bprint_append_data(&s->buffer, text, len);
>      // If it's not utf-8, just use the byte length

Series looks good. Thanks for doing this!


--phil
diff mbox series

Patch

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 2ae5a9bf0b..0632463a63 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -84,7 +84,7 @@  typedef struct {
     uint8_t box_flags;
     StyleBox d;
     uint16_t text_pos;
-    uint16_t byte_count;
+    unsigned byte_count;
     char **fonts;
     int font_count;
     double font_scale_factor;
@@ -584,9 +584,9 @@  static void mov_text_cancel_overrides_cb(void *priv, const char *style_name)
     mov_text_ass_style_set(s, style);
 }
 
-static uint16_t utf8_strlen(const char *text, int len)
+static unsigned utf8_strlen(const char *text, int len)
 {
-    uint16_t i = 0, ret = 0;
+    unsigned i = 0, ret = 0;
     while (i < len) {
         char c = text[i];
         if ((c & 0x80) == 0)
@@ -606,7 +606,7 @@  static uint16_t utf8_strlen(const char *text, int len)
 
 static void mov_text_text_cb(void *priv, const char *text, int len)
 {
-    uint16_t utf8_len = utf8_strlen(text, len);
+    unsigned utf8_len = utf8_strlen(text, len);
     MovTextContext *s = priv;
     av_bprint_append_data(&s->buffer, text, len);
     // If it's not utf-8, just use the byte length