mesa/src/glx
Hal Gentz 1591d1fee5 glx: Fix SEGV due to dereferencing a NULL ptr from XCB-GLX.
When run in optirun, applications that linked to `libGLX.so` and then
proceeded to querying Mesa for extension strings caused a SEGV in Mesa.

`glXQueryExtensionsString` was calling a chain of functions that
eventually led to `__glXQueryServerString`. This function would call
`xcb_glx_query_server_string` then `xcb_glx_query_server_string_reply`.
The latter for some unknown reason returned `NULL`. Passing this `NULL`
to `xcb_glx_query_server_string_string_length` would cause a SEGV as the
function tried to dereference it.

The reason behind the function returning `NULL` is yet to be determined,
however, simply checking that the ptr is not `NULL` resolves this. A
similar check has been added to `__glXGetString` for completeness sake,
although not immediately necessary.

In addition to that, we stumbled into a similar problem in
`AllocAndFetchScreenConfigs` which tries to access the configs to free
them if `__glXQueryServerString` fails. This, of course, SEGVs, because the
configs are yet to have been allocated. Simply continuing past the configs
if their config ptrs are `NULL` resolves this. We also switch to `calloc`
to make sure that the config ptrs are `NULL` by default, and not some
uninitialized value.

Cc: mesa-stable@lists.freedesktop.org
Fixes: 24b8a8cfe8 "glx: implement __glXGetString, hide __glXGetStringFromServer"
Fixes: cb3610e37c "Import the GLX client side library, formerly from xc/lib/GL/glx. Build it "
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Hal Gentz <zegentzy@protonmail.com>
2019-09-04 16:00:10 +00:00
..
apple glx: Fix up glXQueryGLXPbufferSGIX on macOS. 2019-08-23 11:05:23 -04:00
tests glx: Sync <GL/glxext.h> with Khronos 2019-08-22 13:29:04 -04:00
windows glx/windows: Fix compilation with -Werror-format 2019-06-07 11:28:48 -07:00
applegl_glx.c
clientattrib.c
clientinfo.c
compsize.c
create_context.c
dri2.c
dri2.h
dri2_glx.c glx: add support for GLX_ARB_create_context_no_error (v3) 2019-03-12 19:12:21 -04:00
dri2_priv.h glx: Add missing include guards 2018-10-30 06:19:10 -06:00
dri3_glx.c glx: drop unnecessary pointer deref for function calls 2019-08-04 11:26:20 +01:00
dri3_priv.h dri3: Return the current swap interval from glXGetSwapIntervalMESA(). 2019-04-01 16:06:38 -07:00
dri_common.c glx: Add fields for color shifts 2019-08-21 18:36:57 +00:00
dri_common.h glx: add support for GLX_ARB_create_context_no_error (v3) 2019-03-12 19:12:21 -04:00
dri_common_interop.c glx/meson: use full include path for dri_interface.h 2019-03-08 18:00:19 +00:00
dri_common_query_renderer.c glx/meson: use full include path for dri_interface.h 2019-03-08 18:00:19 +00:00
dri_glx.c glx: Move DRI extensions pointer loading to driOpenDriver(). 2018-11-16 15:38:18 -08:00
dri_sarea.h
drisw_glx.c drisw: Try harder to probe whether MIT-SHM works 2019-04-09 09:50:24 +10:00
drisw_priv.h glx: Add missing include guards 2018-10-30 06:19:10 -06:00
driwindows_glx.c
eval.c
g_glxglvnddispatchfuncs.c glx: drop unnecessary pointer deref for function calls 2019-08-04 11:26:20 +01:00
g_glxglvnddispatchindices.h
glx_error.c Revert "glx: Fix synthetic error generation in __glXSendError" 2019-05-08 13:16:44 +10:00
glx_error.h glx: Add missing include guards 2018-10-30 06:19:10 -06:00
glx_pbuffer.c glx: Make __glXGetDrawableAttribute return true sometimes 2019-08-22 13:29:06 -04:00
glx_query.c glx: Fix SEGV due to dereferencing a NULL ptr from XCB-GLX. 2019-09-04 16:00:10 +00:00
glxclient.h mesa: Rename GLX_USE_TLS to USE_ELF_TLS. 2019-08-03 20:18:17 +02:00
glxcmds.c glx: Eliminate glx_config::{rgb,float,colorIndex}Mode 2019-08-20 14:05:07 -04:00
glxconfig.c glx: Eliminate glx_config::{rgb,float,colorIndex}Mode 2019-08-20 14:05:07 -04:00
glxconfig.h glx: Add fields for color shifts 2019-08-21 18:36:57 +00:00
glxcurrent.c mesa: Rename GLX_USE_TLS to USE_ELF_TLS. 2019-08-03 20:18:17 +02:00
glxext.c glx: Fix SEGV due to dereferencing a NULL ptr from XCB-GLX. 2019-09-04 16:00:10 +00:00
glxextensions.c Revert "glx: Unset the direct_support bit for GLX_EXT_import_context" 2019-08-30 17:50:45 -04:00
glxextensions.h glx: add support for GLX_ARB_create_context_no_error (v3) 2019-03-12 19:12:21 -04:00
glxglvnd.c glx: fix glvnd pointer types 2019-06-20 17:21:37 +01:00
glxglvnd.h
glxglvnddispatchfuncs.h
glxhash.c meson: Test for random_r() 2019-07-30 11:49:09 -07:00
glxhash.h
indirect_glx.c
indirect_init.h
indirect_texture_compression.c
indirect_transpose_matrix.c
indirect_vertex_array.c
indirect_vertex_array.h
indirect_vertex_array_priv.h
indirect_vertex_program.c
indirect_window_pos.c
meson.build meson: replace last uses of libxmlconfig with idep_xmlconfig 2019-08-03 00:08:37 +00:00
packrender.h
packsingle.h
pixel.c
pixelstore.c
query_renderer.c
render2.c
renderpix.c
SConscript glx: make xf86vidmode mandatory for direct rendering 2018-11-20 11:13:20 +00:00
single2.c
singlepix.c
vertarr.c
XF86dri.c
xf86dri.h
xf86dristr.h
xfont.c