From: rcombs <rcombs@rcombs.me>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/2] lavc/ass: error if not passed exactly 1 rect
Date: Wed, 8 Mar 2023 15:36:40 -0600
Message-ID: <20230308213640.83444-2-rcombs@rcombs.me> (raw)
In-Reply-To: <20230308213640.83444-1-rcombs@rcombs.me>
This never produced valid output.
---
libavcodec/assenc.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c
index db6fd25dd7..41332d33fb 100644
--- a/libavcodec/assenc.c
+++ b/libavcodec/assenc.c
@@ -45,27 +45,26 @@ static int ass_encode_frame(AVCodecContext *avctx,
unsigned char *buf, int bufsize,
const AVSubtitle *sub)
{
- int i, len, total_len = 0;
+ int len;
- for (i=0; i<sub->num_rects; i++) {
- const char *ass = sub->rects[i]->ass;
-
- if (sub->rects[i]->type != SUBTITLE_ASS) {
- av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
- return AVERROR(EINVAL);
- }
+ if (sub->num_rects != 0) {
+ av_log(avctx, AV_LOG_ERROR, "Only one rect per AVSubtitle is supported in ASS.\n");
+ return AVERROR_INVALIDDATA;
+ }
- len = av_strlcpy(buf+total_len, ass, bufsize-total_len);
+ if (sub->rects[0]->type != SUBTITLE_ASS) {
+ av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
+ return AVERROR(EINVAL);
+ }
- if (len > bufsize-total_len-1) {
- av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
- return AVERROR_BUFFER_TOO_SMALL;
- }
+ len = av_strlcpy(buf, sub->rects[0]->ass, bufsize);
- total_len += len;
+ if (len > bufsize - 1) {
+ av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
+ return AVERROR_BUFFER_TOO_SMALL;
}
- return total_len;
+ return len;
}
#if CONFIG_SSA_ENCODER
--
2.39.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2023-03-08 21:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 21:36 [FFmpeg-devel] [PATCH 1/2] ffmpeg: send only one rect per packet when encoding ASS rcombs
2023-03-08 21:36 ` rcombs [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230308213640.83444-2-rcombs@rcombs.me \
--to=rcombs@rcombs.me \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git