[vlc-commits] [Git][videolan/vlc][master] 2 commits: codec: jpeg: use checked arithmetic for alloc
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Aug 17 08:35:24 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
38d82810 by François Cartegnie at 2026-08-17T08:25:29+00:00
codec: jpeg: use checked arithmetic for alloc
refs #29719
- - - - -
99bc03a4 by François Cartegnie at 2026-08-17T08:25:29+00:00
codec: png: use checked arithmetic for alloc
refs #29719
- - - - -
2 changed files:
- modules/codec/jpeg.c
- modules/codec/png.c
Changes:
=====================================
modules/codec/jpeg.c
=====================================
@@ -33,6 +33,7 @@
#include <jpeglib.h>
#include <setjmp.h>
+#include <stdckdint.h>
/* JPEG_SYS_COMMON_MEMBERS:
* members common to encoder and decoder descriptors
@@ -90,7 +91,7 @@ typedef struct
struct jpeg_compress_struct p_jpeg;
- int i_blocksize;
+ size_t i_blocksize;
int i_quality;
} encoder_sys_t;
@@ -630,7 +631,13 @@ static int OpenEncoder(vlc_object_t *p_this)
p_sys->err.output_message = user_error_message;
p_sys->i_quality = var_GetInteger(p_enc, ENC_CFG_PREFIX "quality");
- p_sys->i_blocksize = 3 * p_enc->fmt_in.video.i_visible_width * p_enc->fmt_in.video.i_visible_height;
+
+ if( ckd_mul( &p_sys->i_blocksize, 3, p_enc->fmt_in.video.i_visible_width ) ||
+ ckd_mul( &p_sys->i_blocksize, p_sys->i_blocksize, p_enc->fmt_in.video.i_visible_height ) )
+ {
+ free( p_sys );
+ return VLC_EGENERIC;
+ }
p_enc->fmt_in.i_codec = p_enc->fmt_in.video.i_chroma = VLC_CODEC_I420;
p_enc->fmt_in.video.color_range = COLOR_RANGE_FULL;
=====================================
modules/codec/png.c
=====================================
@@ -33,6 +33,7 @@
#include <vlc_rand.h>
#include <vlc_ancillary.h>
#include <png.h>
+#include <stdckdint.h>
/* PNG_SYS_COMMON_MEMBERS:
* members common to encoder and decoder descriptors
@@ -74,7 +75,7 @@ static int DecodeBlock ( decoder_t *, block_t * );
typedef struct
{
PNG_SYS_COMMON_MEMBERS
- int i_blocksize;
+ size_t i_blocksize;
} encoder_sys_t;
static int OpenEncoder(vlc_object_t *);
@@ -428,8 +429,9 @@ static int OpenEncoder(vlc_object_t *p_this)
p_sys->p_obj = p_this;
- p_sys->i_blocksize = 3 * p_enc->fmt_in.video.i_visible_width *
- p_enc->fmt_in.video.i_visible_height;
+ if( ckd_mul( &p_sys->i_blocksize, 3, p_enc->fmt_in.video.i_visible_width ) ||
+ ckd_mul( &p_sys->i_blocksize, p_sys->i_blocksize, p_enc->fmt_in.video.i_visible_height ) )
+ return VLC_EGENERIC;
p_enc->fmt_in.i_codec =
p_enc->fmt_in.video.i_chroma = VLC_CODEC_RGB24;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a10627928a84c7a98d0a3800f9156c269e53fa0f...99bc03a405e803509da355cf071d8236f7ddfea6
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a10627928a84c7a98d0a3800f9156c269e53fa0f...99bc03a405e803509da355cf071d8236f7ddfea6
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list