From b9a07e787bd09036b96370bb87fdf841fe380f9f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 9 Sep 2012 14:13:04 +0200 Subject: srtdec: fix unsafe snprintf() return usage Signed-off-by: Michael Niedermayer --- libavcodec/srtdec.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'libavcodec/srtdec.c') diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c index f32521f771..5824091a4d 100644 --- a/libavcodec/srtdec.c +++ b/libavcodec/srtdec.c @@ -60,10 +60,11 @@ static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end, if (x1 >= 0 && y1 >= 0) { if (x2 >= 0 && y2 >= 0 && (x2 != x1 || y2 != y1)) - out += snprintf(out, out_end-out, + snprintf(out, out_end-out, "{\\an1}{\\move(%d,%d,%d,%d)}", x1, y1, x2, y2); else - out += snprintf(out, out_end-out, "{\\an1}{\\pos(%d,%d)}", x1, y1); + snprintf(out, out_end-out, "{\\an1}{\\pos(%d,%d)}", x1, y1); + out += strlen(out); } for (; out < out_end && !end && *in; in++) { @@ -77,7 +78,8 @@ static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end, } while (out[-1] == ' ') out--; - out += snprintf(out, out_end-out, "\\N"); + snprintf(out, out_end-out, "\\N"); + if(out=0; j--) if (stack[j].param[i][0]) { - out += snprintf(out, out_end-out, + snprintf(out, out_end-out, "%s", stack[j].param[i]); + if(out", buffer); @@ -180,7 +186,7 @@ static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end, out -= 2; while (out[-1] == ' ') out--; - out += snprintf(out, out_end-out, "\r\n"); + snprintf(out, out_end-out, "\r\n"); return in; } -- cgit v1.2.3