egl: Restrict multiplication in calloc arguments to use compile-time constants
authorCarl Worth <cworth@cworth.org>
Wed, 3 Sep 2014 21:33:18 +0000 (14:33 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 4 Sep 2014 01:37:02 +0000 (18:37 -0700)
commitecc89e4e42c0eda41de5a37d9d0614d0846e3a3e
tree642361ecaaa9dd405f4b25cf3d18273624547339
parentc35f14f36880eb20f5e54480444e343520e9bec5
egl: Restrict multiplication in calloc arguments to use compile-time constants

As explained in the previous commit, we want to avoid the possibility of
integer-multiplication overflow while allocating buffers.

In these two cases, the final allocation size is the product of three values:
one variable and two that are fixed constants at compile time.

In this commit, we move the explicit multiplication to involve only the
compile-time constants, preventing any overflow from that multiplication, (and
allowing calloc to catch any potential overflow from the remainining implicit
multiplication).

Reviewed-by: Matt Turner <mattst88@gmail.com>
src/egl/drivers/dri2/platform_drm.c
src/egl/drivers/dri2/platform_wayland.c