[PATCH] Stop accessing the attribute array using the attribute name enum.

Robert Ancell robert.ancell at canonical.com
Tue Sep 29 21:07:49 PDT 2015


This was found when compiling for aarch64 (PowerPC):

../../src/smi_video.c: In function 'SMI_ResetVideo':
../../src/smi_video.c:686:45: error: array subscript is above array bounds
[-Werror=array-bounds]
 value = CLAMP(value, SMI_VideoAttributes[i].min_value,

I'm not sure why the other architectures don't pick this up.

--Robert

On Wed, Sep 30, 2015 at 5:02 PM Robert Ancell <robert.ancell at canonical.com>
wrote:

> The array has only two elements but the clamping code was assuming it
> contained
> all the elements in order. This means no clamping is now done but at least
> it
> wont read off the end of the array.
>
> Signed-off-by: Robert Ancell <robert.ancell at canonical.com>
> ---
>  src/smi_video.c | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/src/smi_video.c b/src/smi_video.c
> index 27df68d..a13668e 100644
> --- a/src/smi_video.c
> +++ b/src/smi_video.c
> @@ -681,10 +681,6 @@ SetAttr(ScrnInfoPtr pScrn, int i, int value)
>
>      if (i < XV_ENCODING || i > XV_HUE)
>         return BadMatch;
> -
> -    /* clamps value to attribute range */
> -    value = CLAMP(value, SMI_VideoAttributes[i].min_value,
> -                 SMI_VideoAttributes[i].max_value);
>
>      if (i == XV_BRIGHTNESS) {
>         int my_value = (value <= 128? value + 128 : value - 128);
> --
> 2.5.0
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20150930/e050caa9/attachment.html>


More information about the xorg-devel mailing list