summaryrefslogtreecommitdiffstats
path: root/libavcodec/assenc.c
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2013-09-08 18:23:44 +0200
committerClément Bœsch <u@pkh.me>2013-09-08 18:50:25 +0200
commit860a0810583f54ccbde912aebda8711f18eab8eb (patch)
treea03d57c3175e40fa1c095cb75678b63ed45c2065 /libavcodec/assenc.c
parent378a830e7b9a5e023c2f7eece6d7260016dfd13b (diff)
downloadffmpeg-streaming-860a0810583f54ccbde912aebda8711f18eab8eb.zip
ffmpeg-streaming-860a0810583f54ccbde912aebda8711f18eab8eb.tar.gz
avcodec/assenc: fix potential overread.
Diffstat (limited to 'libavcodec/assenc.c')
-rw-r--r--libavcodec/assenc.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c
index 7b8a540..5dc3b09 100644
--- a/libavcodec/assenc.c
+++ b/libavcodec/assenc.c
@@ -80,9 +80,16 @@ static int ass_encode_frame(AVCodecContext *avctx,
* will be "Marked=N" instead of the layer num, so we will
* have layer=0, which is fine. */
layer = strtol(ass, &p, 10);
- if (*p) p += strcspn(p, ",") + 1; // skip layer or marked
- if (*p) p += strcspn(p, ",") + 1; // skip start timestamp
- if (*p) p += strcspn(p, ",") + 1; // skip end timestamp
+
+#define SKIP_ENTRY(ptr) do { \
+ char *sep = strchr(ptr, ','); \
+ if (sep) \
+ ptr = sep + 1; \
+} while (0)
+
+ SKIP_ENTRY(p); // skip layer or marked
+ SKIP_ENTRY(p); // skip start timestamp
+ SKIP_ENTRY(p); // skip end timestamp
snprintf(ass_line, sizeof(ass_line), "%d,%ld,%s", ++s->id, layer, p);
ass_line[strcspn(ass_line, "\r\n")] = 0;
ass = ass_line;
OpenPOWER on IntegriCloud