summaryrefslogtreecommitdiff
path: root/libavcodec/jpeglsenc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-29 13:38:16 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-05-15 11:32:15 +0200
commit79402e2c36301fb0ecb1ff797a8de7f79b178c70 (patch)
tree81bed444001cd3a639cf087f953345bec3521a2b /libavcodec/jpeglsenc.c
parent59032494e81a1a65c0b960aaae7ec4c2cc9db35a (diff)
downloadffmpeg-79402e2c36301fb0ecb1ff797a8de7f79b178c70.tar.gz
avcodec/jpeglsenc: Check for invalid dimensions
The dimensions are written on two bytes. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/jpeglsenc.c')
-rw-r--r--libavcodec/jpeglsenc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 3e73b04c0e..15d9204b1d 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -413,6 +413,15 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
+static av_cold int encode_jpegls_init(AVCodecContext *avctx)
+{
+ if ((avctx->width | avctx->height) > UINT16_MAX) {
+ av_log(avctx, AV_LOG_ERROR, "Dimensions exceeding 65535x65535\n");
+ return AVERROR(EINVAL);
+ }
+ return 0;
+}
+
#define OFFSET(x) offsetof(JPEGLSContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
@@ -439,6 +448,7 @@ const AVCodec ff_jpegls_encoder = {
.priv_data_size = sizeof(JPEGLSContext),
.priv_class = &jpegls_class,
.capabilities = AV_CODEC_CAP_FRAME_THREADS,
+ .init = encode_jpegls_init,
.encode2 = encode_picture_ls,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24,