ass_split: fix out of array access in ass_split()
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 11 Jan 2013 01:51:27 +0000 (02:51 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 11 Jan 2013 01:51:54 +0000 (02:51 +0100)
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/ass_split.c

index 62c8db9..413e9c8 100644 (file)
@@ -285,14 +285,17 @@ static int ass_split(ASSSplitContext *ctx, const char *buf)
 
     while (buf && *buf) {
         if (sscanf(buf, "[%15[0-9A-Za-z+ ]]%c", section, &c) == 2) {
-            buf += strcspn(buf, "\n") + 1;
+            buf += strcspn(buf, "\n");
+            buf += !!*buf;
             for (i=0; i<FF_ARRAY_ELEMS(ass_sections); i++)
                 if (!strcmp(section, ass_sections[i].section)) {
                     ctx->current_section = i;
                     buf = ass_split_section(ctx, buf);
                 }
-        } else
-            buf += strcspn(buf, "\n") + 1;
+        } else {
+            buf += strcspn(buf, "\n");
+            buf += !!*buf;
+        }
     }
     return buf ? 0 : AVERROR_INVALIDDATA;
 }