]> git.xonotic.org Git - xonotic/darkplaces.git/commit
net: fix UB in VM_CL_getstati() and when sending the `items` stat
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 5 May 2024 19:13:34 +0000 (05:13 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 9 May 2024 03:07:35 +0000 (13:07 +1000)
commit9aff57968fdea0b6792a8826d101788f31fdf1a3
tree0fcb1fb04949e0de42b92255ed49fe3e673d05f0
parent43f63d6ac7120d5cd17300d801856a94e740e9c0
net: fix UB in VM_CL_getstati() and when sending the `items` stat

Simplifies the shifting in VM_CL_getstati() to avoid signed integer
overflow when the high bits are read with the arguments 23 and 9 (as
done in "quake15" and "ad" mods).

Refactors VM_CL_getstati() slightly, returns 0 when the index is out of
range (instead of whatever happened to be in that memory).

Masks off the bits that will overflow when packing the `items` stat for
sending (otherwise corruption of the low bits could occur on x86).

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
clvm_cmds.c
sv_send.c