From 43f63d6ac7120d5cd17300d801856a94e740e9c0 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Mon, 6 May 2024 00:14:52 +1000 Subject: [PATCH] Q3BSP: fix UB when loading certain maps Signed-off-by: bones_was_here --- model_brush.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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); -- 2.39.2