aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2013-01-03 07:25:45 +0100
committerClément Bœsch <ubitux@gmail.com>2013-01-03 07:25:47 +0100
commit3fa642d60f428a36413498a191eb2ee319fe4445 (patch)
treebb52e50a620674614da7f43ff3c33e15134c4dca /libavcodec
parent52334f5be2ef31a5c836f689f3ab95b25bad026a (diff)
downloadffmpeg-3fa642d60f428a36413498a191eb2ee319fe4445.tar.gz
subviewer: sanitize packets.
The data does not contain timing or trailing line breaks anymore. In addition to being less idiotic, it is consistent with other codecs and thus allows more switches between formats and codecs. It also fixes the issue of the trailing line returns being simple \n instead of CRLF in the ASS rectangle dialogue (this is the reason of the FATE update).
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/subviewerdec.c15
-rw-r--r--libavcodec/version.h2
2 files changed, 11 insertions, 6 deletions
diff --git a/libavcodec/subviewerdec.c b/libavcodec/subviewerdec.c
index 0e8be90e78..7580cbe679 100644
--- a/libavcodec/subviewerdec.c
+++ b/libavcodec/subviewerdec.c
@@ -31,17 +31,13 @@
static int subviewer_event_to_ass(AVBPrint *buf, const char *p)
{
while (*p) {
- char c;
-
- if (sscanf(p, "%*u:%*u:%*u.%*u,%*u:%*u:%*u.%*u%c", &c) == 1)
- p += strcspn(p, "\n") + 1;
if (!strncmp(p, "[br]", 4)) {
av_bprintf(buf, "\\N");
p += 4;
} else {
if (p[0] == '\n' && p[1])
av_bprintf(buf, "\\N");
- else if (*p != '\r')
+ else if (*p != '\n' && *p != '\r')
av_bprint_chars(buf, *p, 1);
p++;
}
@@ -54,10 +50,19 @@ static int subviewer_event_to_ass(AVBPrint *buf, const char *p)
static int subviewer_decode_frame(AVCodecContext *avctx,
void *data, int *got_sub_ptr, AVPacket *avpkt)
{
+ char c;
AVSubtitle *sub = data;
const char *ptr = avpkt->data;
AVBPrint buf;
+ /* To be removed later */
+ if (sscanf(ptr, "%*u:%*u:%*u.%*u,%*u:%*u:%*u.%*u%c", &c) == 1) {
+ av_log(avctx, AV_LOG_ERROR, "AVPacket is not clean (contains timing "
+ "information). You need to upgrade your libavformat or "
+ "sanitize your packet.\n");
+ return AVERROR_INVALIDDATA;
+ }
+
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
// note: no need to rescale pts & duration since they are in the same
// timebase as ASS (1/100)
diff --git a/libavcodec/version.h b/libavcodec/version.h
index b4608a2cb0..670a875964 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
#define LIBAVCODEC_VERSION_MAJOR 54
#define LIBAVCODEC_VERSION_MINOR 85
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \