From 63e4b9b18a339440dbd0b052c0952e9497f9b5c1 Mon Sep 17 00:00:00 2001 From: Nikita Edel Date: Wed, 11 Mar 2026 12:32:59 +0100 Subject: [PATCH] next little patch of ub, unallocated variable, s int overflow --- .../Network/PlatformNetworkManagerStub.cpp | 2 + Minecraft.World/WorldGen/Layers/Layer.cpp | 43 ++++++++++--------- Minecraft.World/WorldGen/Layers/Layer.h | 2 +- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp index f9d4ae1b6..9dfc45a17 100644 --- a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp +++ b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp @@ -119,6 +119,7 @@ bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkMa m_pGameNetworkManager = pGameNetworkManager; m_flagIndexSize = flagIndexSize; g_pPlatformNetworkManager = this; + m_pIQNet = new IQNet(); for( int i = 0; i < XUSER_MAX_COUNT; i++ ) { playerChangedCallback[ i ] = NULL; @@ -154,6 +155,7 @@ bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkMa void CPlatformNetworkManagerStub::Terminate() { + //TODO: 4jcraft, no release of ressources } int CPlatformNetworkManagerStub::GetJoiningReadyPercentage() diff --git a/Minecraft.World/WorldGen/Layers/Layer.cpp b/Minecraft.World/WorldGen/Layers/Layer.cpp index 1718172a2..286fd3827 100644 --- a/Minecraft.World/WorldGen/Layers/Layer.cpp +++ b/Minecraft.World/WorldGen/Layers/Layer.cpp @@ -111,38 +111,41 @@ Layer::Layer(__int64 seedMixup) { parent = nullptr; + // 4jcraft added all those calls abecause of signed int overflow this->seedMixup = seedMixup; - this->seedMixup *= this->seedMixup * 6364136223846793005l + 1442695040888963407l; - this->seedMixup += seedMixup; - this->seedMixup *= this->seedMixup * 6364136223846793005l + 1442695040888963407l; - this->seedMixup += seedMixup; - this->seedMixup *= this->seedMixup * 6364136223846793005l + 1442695040888963407l; - this->seedMixup += seedMixup; + this->seedMixup *= (uint64_t) this->seedMixup * 6364136223846793005l + 1442695040888963407l; + this->seedMixup = (uint64_t) this->seedMixup + seedMixup; + this->seedMixup *= (uint64_t) this->seedMixup * 6364136223846793005l + 1442695040888963407l; + this->seedMixup = (uint64_t) this->seedMixup + seedMixup; + this->seedMixup *= (uint64_t) this->seedMixup * 6364136223846793005l + 1442695040888963407l; + this->seedMixup = (uint64_t) this->seedMixup + seedMixup; } void Layer::init(__int64 seed) { this->seed = seed; if (parent != NULL) parent->init(seed); - this->seed *= this->seed * 6364136223846793005l + 1442695040888963407l; - this->seed += seedMixup; - this->seed *= this->seed * 6364136223846793005l + 1442695040888963407l; - this->seed += seedMixup; - this->seed *= this->seed * 6364136223846793005l + 1442695040888963407l; - this->seed += seedMixup; + // 4jcraft added all those calls abecause of signed int overflow + this->seed *= (uint64_t) this->seed * 6364136223846793005l + 1442695040888963407l; + this->seed = (uint64_t) this->seed + seedMixup; + this->seed *= (uint64_t) this->seed * 6364136223846793005l + 1442695040888963407l; + this->seed = (uint64_t) this->seed + seedMixup; + this->seed *= (uint64_t) this->seed * 6364136223846793005l + 1442695040888963407l; + this->seed = (uint64_t) this->seed + seedMixup; } void Layer::initRandom(__int64 x, __int64 y) { rval = seed; - rval *= rval * 6364136223846793005l + 1442695040888963407l; - rval += x; - rval *= rval * 6364136223846793005l + 1442695040888963407l; - rval += y; - rval *= rval * 6364136223846793005l + 1442695040888963407l; - rval += x; - rval *= rval * 6364136223846793005l + 1442695040888963407l; - rval += y; + // 4jcraft added all those calls abecause of signed int overflow + rval *= (uint64_t) rval * 6364136223846793005l + 1442695040888963407l; + rval += (uint64_t) x; + rval *= (uint64_t) rval * 6364136223846793005l + 1442695040888963407l; + rval += (uint64_t) y; + rval *= (uint64_t) rval * 6364136223846793005l + 1442695040888963407l; + rval += (uint64_t) x; + rval *= (uint64_t) rval * 6364136223846793005l + 1442695040888963407l; + rval += (uint64_t) y; } int Layer::nextRandom(int max) diff --git a/Minecraft.World/WorldGen/Layers/Layer.h b/Minecraft.World/WorldGen/Layers/Layer.h index 2104d219d..ec1598b4f 100644 --- a/Minecraft.World/WorldGen/Layers/Layer.h +++ b/Minecraft.World/WorldGen/Layers/Layer.h @@ -4,7 +4,7 @@ class LevelType; -#ifndef _CONTENT_PACAKGE +#ifndef _CONTENT_PACKAGE #define _BIOME_OVERRIDE #endif