xserver/glx
Nathan Kidd 1af7e6c89d glx: Don't blindly write 8 bytes in GLX single replies
Previously we leaked stack when invalid enum parameters were
specified and caused __glGet*_size functions to return a 0 size.

Further, we read out-of-bounds (and leaked) when the input data was less
than 8 bytes (__glXDispSwap_GetFramebufferAttachmentParameteriv and
__glXDisp_GetRenderbufferParameteriv).

Now we only write a single element in the reply padding, and only when there
is a single element. This is what the Mesa client-side libGL expects, and
restores original GLX server behaviour, matching both pre-public (1996) SGI GLX
and XFree86 4.

The main risk of this change is if we have any error in element count or size;
previously it may not have mattered but now it does.

There are no piglit result changes from this modification using either mesa
libGLX or NVIDIA libGLX.

For performance considerations, an extra conditional and variable-length
memcpy has no meaningful impact on the indirect rendering pipeline cost.

There is still the possiblity to leak if our size checks allow an enum that
the GL implemention does not. Guarding against that requires zero-initializing
all temp storage, which wants re-evaluation of the blind 200-byte buffers
used for many calls and thus is a much bigger change.

Signed-off-by: Nathan Kidd <nkidd@rocketsoftware.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1647>
(cherry picked from commit a4df686888)
2026-01-25 10:40:02 -08:00
..
clientinfo.c glx: drop obsolete glxbyteorder.h 2026-01-25 10:39:58 -08:00
createcontext.c GLX: fix context render type queries 2020-11-26 20:07:55 +00:00
extension_string.c glx: Implement GLX_EXT_get_drawable_type 2020-09-28 17:16:24 +00:00
extension_string.h glx: Implement GLX_EXT_get_drawable_type 2020-09-28 17:16:24 +00:00
glxcmds.c glx: DoQueryContext(): explicitly use reply buf type defined by spec 2026-01-25 10:39:58 -08:00
glxcmdsswap.c glx: Use vnd layer for dispatch (v4) 2018-02-14 17:04:44 -05:00
glxcontext.h GLX: fix context render type queries 2020-11-26 20:07:55 +00:00
glxdrawable.h Add Windows-DRI extension 2016-09-15 20:10:29 +01:00
glxdri2.c treewide: replace xnfstrdup() calls by XNFstrdup() 2026-01-25 10:39:55 -08:00
glxdricommon.c glx/dri: Filter out fbconfigs that don't have a supported pixmap format 2021-12-19 10:26:03 +00:00
glxdricommon.h glx: remove unused systemTimeExtension 2017-09-08 11:23:35 -07:00
glxdriswrast.c dix: Call SourceValidate before GetImage 2019-10-30 16:26:01 +00:00
glxext.c rename remaining RT_* defines to X11_RESTYPE_* 2026-01-19 12:48:30 -08:00
glxext.h glx: Fix GLX_CONTEXT_RELEASE_BEHAVIOR_ARB handling 2019-05-01 14:38:09 +00:00
glxscreens.c treewide: replace xnfalloc() calls to XNFalloc() 2026-01-25 10:39:55 -08:00
glxscreens.h glx: Use vnd layer for dispatch (v4) 2018-02-14 17:04:44 -05:00
glxserver.h glx: Enable GLX_ARB_create_context_no_error (v2) 2018-02-26 10:18:58 -05:00
glxutil.h Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
indirect_dispatch.c glx: drop obsolete warnings on files being generated 2026-01-25 10:39:58 -08:00
indirect_dispatch.h Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
indirect_dispatch_swap.c glx: drop obsolete warnings on files being generated 2026-01-25 10:39:58 -08:00
indirect_program.c glx: drop obsolete glxbyteorder.h 2026-01-25 10:39:58 -08:00
indirect_reqsize.c glx: drop obsolete glxbyteorder.h 2026-01-25 10:39:58 -08:00
indirect_reqsize.h drop remains of support for old Sun compilers 2026-01-19 12:32:18 -08:00
indirect_size.h drop remains of support for old Sun compilers 2026-01-19 12:32:18 -08:00
indirect_size_get.c drop remains of support for old Sun compilers 2026-01-19 12:32:18 -08:00
indirect_size_get.h drop remains of support for old Sun compilers 2026-01-19 12:32:18 -08:00
indirect_table.c Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
indirect_table.h Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
indirect_texture_compression.c glx: drop obsolete glxbyteorder.h 2026-01-25 10:39:58 -08:00
indirect_util.c glx: Don't blindly write 8 bytes in GLX single replies 2026-01-25 10:40:02 -08:00
indirect_util.h Drop trailing whitespaces 2014-11-12 10:25:00 +10:00
meson.build meson: hide C API if Xorg is disabled (like autotools) 2021-03-11 00:22:36 +00:00
render2.c glx: Convert non-generated function pointer thunking 2013-12-10 08:02:42 -08:00
render2swap.c glx: Convert non-generated function pointer thunking 2013-12-10 08:02:42 -08:00
renderpix.c glx: convert to direct GL dispatch (v2) 2013-10-29 12:29:16 -04:00
renderpixswap.c glx: convert to direct GL dispatch (v2) 2013-10-29 12:29:16 -04:00
rensize.c glx: Synchronize Xserver glx/rensize.c with mesa src/glx/compsize.c 2015-10-06 11:15:31 -04:00
single2.c glx: assign at declaration 2026-01-25 10:39:58 -08:00
single2swap.c glx: assign at declaration 2026-01-25 10:39:58 -08:00
singlepix.c glx: Remove __glXReply 2017-06-20 16:39:23 -04:00
singlepixswap.c glx: Remove __glXReply 2017-06-20 16:39:23 -04:00
singlesize.c glx: Fix out-of-bounds reads from negative return 2026-01-25 10:40:02 -08:00
singlesize.h Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
swap_interval.c glx: drop obsolete glxbyteorder.h 2026-01-25 10:39:58 -08:00
unpack.h glx: Remove __glXReply 2017-06-20 16:39:23 -04:00
vnd_dispatch_stubs.c glx: Import glxvnd server module (v2) 2018-02-14 17:04:35 -05:00
vndcmds.c glx: move private definitions from vndserver.h to vndserver_priv.h 2026-01-19 12:32:18 -08:00
vndext.c prevent name clash on Windows w/ RT_* defines 2026-01-19 12:48:30 -08:00
vndserver.h glx: move private definitions from vndserver.h to vndserver_priv.h 2026-01-19 12:32:18 -08:00
vndserver_priv.h glx: move private definitions from vndserver.h to vndserver_priv.h 2026-01-19 12:32:18 -08:00
vndservermapping.c glx: move private definitions from vndserver.h to vndserver_priv.h 2026-01-19 12:32:18 -08:00
vndservervendor.c glx: Import glxvnd server module (v2) 2018-02-14 17:04:35 -05:00
vndservervendor.h glx: Import glxvnd server module (v2) 2018-02-14 17:04:35 -05:00
xfont.c glx: Use vnd layer for dispatch (v4) 2018-02-14 17:04:44 -05:00