Out of bounds array access in XGI_New_SetCRT1CRTC
If you add the standard X.Org warning/error flags ($BASE_CFLAGS
) to AM_CFLAGS
in src/Makefile.am
and compile with gcc 13, then the build fails with:
In function ‘XGI_New_SetCRT1CRTC’,
inlined from ‘XGI_New_SetCRT1Group’ at init.c:868:6,
inlined from ‘XGIBIOSSetModeCRT1’ at init.c:1032:4:
init.c:555:49: error: array subscript 16 is above array bounds of ‘const UCHAR[15]’ {aka ‘const unsigned char[15]’} [-Werror=array-bounds=]
555 | temp = XGI_Pr->XGINEWUB_CRT1Table[index].CR[16] & 0xE0;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
In file included from init.h:57:
vb_struct.h: In function ‘XGIBIOSSetModeCRT1’:
vb_struct.h:378:9: note: while referencing ‘CR’
378 | UCHAR CR[15];
| ^~
In function ‘XGI_New_SetCRT1CRTC’,
inlined from ‘XGI_New_SetCRT1Group’ at init.c:868:6,
inlined from ‘XGIBIOSSetModeCRT1’ at init.c:1032:4:
init.c:558:51: error: array subscript 16 is above array bounds of ‘const UCHAR[15]’ {aka ‘const unsigned char[15]’} [-Werror=array-bounds=]
558 | temp = ((XGI_Pr->XGINEWUB_CRT1Table[index].CR[16]) & 0x01) << 5;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
vb_struct.h: In function ‘XGIBIOSSetModeCRT1’:
vb_struct.h:378:9: note: while referencing ‘CR’
378 | UCHAR CR[15];
| ^~