mirror of
https://gitlab.freedesktop.org/xorg/lib/libx11.git
synced 2026-05-22 05:48:15 +02:00
The _XimCacheStruct structure is followed in memory by two strings containing
fname and encoding. The memory was accessed using the last member of the
structure `char fname[1]`. That is a lie, prohibits us from using sizeof and
confuses checkers. Lets declare it properly as a flexible array, so compilers
don't complain about writing past that array. As bonus we can replace the
XOffsetOf with regular sizeof.
Fixes GCC8 error:
In function 'strcpy',
inlined from '_XimWriteCachedDefaultTree' at imLcIm.c:479:5,
inlined from '_XimCreateDefaultTree' at imLcIm.c:616:2,
inlined from '_XimLocalOpenIM' at imLcIm.c:700:5:
/usr/include/bits/string_fortified.h:90:10: error: '__builtin_strcpy'
forming offset 2 is out of the bounds [0, 1] [-Werror=array-bounds]
return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
Caused by this line seemingly writing past the fname[1] array:
imLcIm.c:479: strcpy (m->fname+strlen(name)+1, encoding);
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
||
|---|---|---|
| .. | ||
| imCallbk.c | ||
| imDefFlt.c | ||
| imDefIc.c | ||
| imDefIm.c | ||
| imDefLkup.c | ||
| imDispch.c | ||
| imEvToWire.c | ||
| imExten.c | ||
| imImSw.c | ||
| imInsClbk.c | ||
| imInt.c | ||
| imLcFlt.c | ||
| imLcGIc.c | ||
| imLcIc.c | ||
| imLcIm.c | ||
| imLcLkup.c | ||
| imLcPrs.c | ||
| imLcSIc.c | ||
| imRm.c | ||
| imRmAttr.c | ||
| imThaiFlt.c | ||
| imThaiIc.c | ||
| imThaiIm.c | ||
| imTrans.c | ||
| imTransR.c | ||
| imTrX.c | ||
| Makefile.am | ||