[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: core: use <stdckdint.h>
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Sep 24 08:33:22 UTC 2026
Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC
Commits:
ad36aff0 by Rémi Denis-Courmont at 2026-09-23T07:31:05+02:00
core: use <stdckdint.h>
(cherry picked from commit 444d71bf2affe6146c951708f2065ab3baccdfe1) (edited)
edited:
- only keep the part about picture.c
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
682660f2 by Steve Lhomme at 2026-09-23T07:45:19+02:00
picture: check each plane dimension doesn't overflow
Fixes #28980
Reported-by: Omri Dar <omri.d at remedio.io>
(cherry picked from commit d1ebcdff54ccf58a9af589d9b70b0e094df7c97f) (rebased)
rebased:
- VLC 3 still has this line:
Hack: append two scan lines for some SIMD assembler
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
1 changed file:
- src/misc/picture.c
Changes:
=====================================
src/misc/picture.c
=====================================
@@ -33,6 +33,7 @@
#endif
#include <assert.h>
#include <limits.h>
+#include <stdckdint.h>
#include <vlc_common.h>
#include "picture.h"
@@ -133,8 +134,8 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
unsigned width, height;
- if (unlikely(add_overflow(fmt->i_width, i_modulo_w - 1, &width))
- || unlikely(add_overflow(fmt->i_height, i_modulo_h - 1, &height)))
+ if (unlikely(ckd_add(&width, fmt->i_width, i_modulo_w - 1))
+ || unlikely(ckd_add(&height, fmt->i_height, i_modulo_h - 1)))
return VLC_EGENERIC;
width = width / i_modulo_w * i_modulo_w;
@@ -144,10 +145,6 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
if (unlikely(add_overflow(height, 2 * i_ratio_h, &height)))
return VLC_EGENERIC;
- /* plane_t uses 'int'. */
- if (unlikely(width > INT_MAX) || unlikely(height > INT_MAX))
- return VLC_EGENERIC;
-
for( unsigned i = 0; i < p_dsc->plane_count; i++ )
{
plane_t *p = &p_picture->p[i];
@@ -158,10 +155,26 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
assert(h->den >= h->num);
assert(w->den >= w->num);
- p->i_lines = height * h->num / h->den;
+ unsigned mul_height;
+ if (unlikely(ckd_mul(&mul_height, height, h->num)))
+ return VLC_EGENERIC;
+ mul_height = mul_height / h->den;
+ if (unlikely(mul_height > INT_MAX))
+ return VLC_EGENERIC;
+
+ p->i_lines = mul_height;
p->i_visible_lines = (fmt->i_visible_height + (h->den - 1)) / h->den * h->num;
- p->i_pitch = width * w->num / w->den * p_dsc->pixel_size;
+ unsigned mul_width;
+ if (unlikely(ckd_mul(&mul_width, width, w->num)))
+ return VLC_EGENERIC;
+ mul_width = mul_width / w->den;
+ if (unlikely(ckd_mul(&mul_width, mul_width, p_dsc->pixel_size)))
+ return VLC_EGENERIC;
+ if (unlikely(mul_width > INT_MAX))
+ return VLC_EGENERIC;
+
+ p->i_pitch = mul_width;
p->i_visible_pitch = (fmt->i_visible_width + (w->den - 1)) / w->den * w->num
* p_dsc->pixel_size;
p->i_pixel_pitch = p_dsc->pixel_size;
@@ -265,8 +278,8 @@ picture_t *picture_NewFromFormat(const video_format_t *restrict fmt)
{
const plane_t *p = &pic->p[i];
- if (unlikely(mul_overflow(p->i_pitch, p->i_lines, &plane_sizes[i]))
- || unlikely(add_overflow(pic_size, plane_sizes[i], &pic_size)))
+ if (unlikely(ckd_mul(&plane_sizes[i], p->i_pitch, p->i_lines))
+ || unlikely(ckd_add(&pic_size, pic_size, plane_sizes[i])))
goto error;
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6de05adcbaf2e8b85fe86aad4169393098628119...682660f248068aab15062a9ebc8feeb9f5816e64
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6de05adcbaf2e8b85fe86aad4169393098628119...682660f248068aab15062a9ebc8feeb9f5816e64
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