From: bones_was_here Date: Sun, 5 May 2024 14:14:52 +0000 (+1000) Subject: Q3BSP: fix UB when loading certain maps X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=43f63d6ac7120d5cd17300d801856a94e740e9c0;p=xonotic%2Fdarkplaces.git Q3BSP: fix UB when loading certain maps Signed-off-by: bones_was_here --- diff --git a/model_brush.c b/model_brush.c index 19c17a40..35d12f00 100644 --- a/model_brush.c +++ b/model_brush.c @@ -6360,8 +6360,9 @@ static void Mod_Q3BSP_LoadLeafs(lump_t *l) for (j = 0;j < 3;j++) { // yes the mins/maxs are ints - out->mins[j] = LittleLong(in->mins[j]) - 1; - out->maxs[j] = LittleLong(in->maxs[j]) + 1; + // bones_was_here: the cast prevents signed underflow with poon-wood.bsp + out->mins[j] = (vec_t)LittleLong(in->mins[j]) - 1; + out->maxs[j] = (vec_t)LittleLong(in->maxs[j]) + 1; } n = LittleLong(in->firstleafface); c = LittleLong(in->numleaffaces);