From: Paul B Mahol <onemda@gmail.com> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] avcodec/yuv4enc: do not read past end of input in case of odd height Date: Wed, 6 Sep 2023 02:35:23 +0200 Message-ID: <CAPYw7P7-mNMfw0tXBPPtH2CWZk0K4Vg1jcYUMTbG_=DjyYgk2A@mail.gmail.com> (raw) [-- Attachment #1: Type: text/plain, Size: 10 bytes --] Attached. [-- Attachment #2: 0001-avcodec-yuv4enc-do-not-read-past-end-of-input-in-cas.patch --] [-- Type: text/x-patch, Size: 1383 bytes --] From 8295be1415649255b26cfdb0308d7be208711b4d Mon Sep 17 00:00:00 2001 From: Paul B Mahol <onemda@gmail.com> Date: Wed, 6 Sep 2023 02:27:56 +0200 Subject: [PATCH] avcodec/yuv4enc: do not read past end of input in case of odd height Signed-off-by: Paul B Mahol <onemda@gmail.com> --- libavcodec/yuv4enc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libavcodec/yuv4enc.c b/libavcodec/yuv4enc.c index 8123260d5d..dd1874ff25 100644 --- a/libavcodec/yuv4enc.c +++ b/libavcodec/yuv4enc.c @@ -41,7 +41,7 @@ static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt, u = pic->data[1]; v = pic->data[2]; - for (i = 0; i < avctx->height + 1 >> 1; i++) { + for (i = 0; i < avctx->height >> 1; i++) { for (j = 0; j < avctx->width + 1 >> 1; j++) { *dst++ = u[j] ^ 0x80; *dst++ = v[j] ^ 0x80; @@ -55,6 +55,17 @@ static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt, v += pic->linesize[2]; } + if (avctx->height & 1) { + for (j = 0; j < avctx->width + 1 >> 1; j++) { + *dst++ = u[j] ^ 0x80; + *dst++ = v[j] ^ 0x80; + *dst++ = y[2 * j ]; + *dst++ = y[2 * j + 1]; + *dst++ = y[2 * j ]; + *dst++ = y[2 * j + 1]; + } + } + *got_packet = 1; return 0; } -- 2.39.1 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ 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".
next reply other threads:[~2023-09-06 0:28 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-06 0:35 Paul B Mahol [this message] 2023-09-06 6:16 ` Tomas Härdin 2023-09-06 11:18 ` Anton Khirnov 2023-09-06 11:33 ` Andreas Rheinhardt
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='CAPYw7P7-mNMfw0tXBPPtH2CWZk0K4Vg1jcYUMTbG_=DjyYgk2A@mail.gmail.com' \ --to=onemda@gmail.com \ --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