You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
srtdec: fix unsafe snprintf() return usage
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -60,10 +60,11 @@ static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
|
|||||||
|
|
||||||
if (x1 >= 0 && y1 >= 0) {
|
if (x1 >= 0 && y1 >= 0) {
|
||||||
if (x2 >= 0 && y2 >= 0 && (x2 != x1 || y2 != y1))
|
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);
|
"{\\an1}{\\move(%d,%d,%d,%d)}", x1, y1, x2, y2);
|
||||||
else
|
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++) {
|
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] == ' ')
|
while (out[-1] == ' ')
|
||||||
out--;
|
out--;
|
||||||
out += snprintf(out, out_end-out, "\\N");
|
snprintf(out, out_end-out, "\\N");
|
||||||
|
if(out<out_end) out += strlen(out);
|
||||||
line_start = 1;
|
line_start = 1;
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
@@ -110,8 +112,9 @@ static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
|
|||||||
if (stack[sptr-1].param[i][0])
|
if (stack[sptr-1].param[i][0])
|
||||||
for (j=sptr-2; j>=0; j--)
|
for (j=sptr-2; j>=0; j--)
|
||||||
if (stack[j].param[i][0]) {
|
if (stack[j].param[i][0]) {
|
||||||
out += snprintf(out, out_end-out,
|
snprintf(out, out_end-out,
|
||||||
"%s", stack[j].param[i]);
|
"%s", stack[j].param[i]);
|
||||||
|
if(out<out_end) out += strlen(out);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -145,13 +148,16 @@ static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
|
|||||||
param++;
|
param++;
|
||||||
}
|
}
|
||||||
for (i=0; i<PARAM_NUMBER; i++)
|
for (i=0; i<PARAM_NUMBER; i++)
|
||||||
if (stack[sptr].param[i][0])
|
if (stack[sptr].param[i][0]) {
|
||||||
out += snprintf(out, out_end-out,
|
snprintf(out, out_end-out,
|
||||||
"%s", stack[sptr].param[i]);
|
"%s", stack[sptr].param[i]);
|
||||||
|
if(out<out_end) out += strlen(out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (!buffer[1] && strspn(buffer, "bisu") == 1) {
|
} else if (!buffer[1] && strspn(buffer, "bisu") == 1) {
|
||||||
out += snprintf(out, out_end-out,
|
snprintf(out, out_end-out,
|
||||||
"{\\%c%d}", buffer[0], !tag_close);
|
"{\\%c%d}", buffer[0], !tag_close);
|
||||||
|
if(out<out_end) out += strlen(out);
|
||||||
} else {
|
} else {
|
||||||
unknown = 1;
|
unknown = 1;
|
||||||
snprintf(tmp, sizeof(tmp), "</%s>", buffer);
|
snprintf(tmp, sizeof(tmp), "</%s>", buffer);
|
||||||
@@ -180,7 +186,7 @@ static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
|
|||||||
out -= 2;
|
out -= 2;
|
||||||
while (out[-1] == ' ')
|
while (out[-1] == ' ')
|
||||||
out--;
|
out--;
|
||||||
out += snprintf(out, out_end-out, "\r\n");
|
snprintf(out, out_end-out, "\r\n");
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user