From e79ff0510d1e0e736dc5e9d0c99143cb828b7bb9 Mon Sep 17 00:00:00 2001 From: SirHumza <204067870+SirHumza@users.noreply.github.com> Date: Sat, 19 Sep 2026 10:28:59 +0200 Subject: [PATCH] tls: local xorshift fallback instead of process-global rand --- orbisrpc/tls.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/orbisrpc/tls.c b/orbisrpc/tls.c index ce11163..6297dd2 100644 --- a/orbisrpc/tls.c +++ b/orbisrpc/tls.c @@ -45,9 +45,12 @@ static int orbis_poll(void *data, unsigned char *out, size_t len, size_t *olen){ close(fd); if(got == len){ *olen = len; return 0; } } - /* fallback: time + address jitter (weak, but keeps us functional) */ - srand((unsigned)(time(NULL) ^ (uintptr_t)out)); - for(size_t i = 0; i < len; i++) out[i] = (unsigned char)rand(); + /* fallback: time + address jitter (weak, but keeps us functional). + * Local xorshift on purpose: rand()/srand() would mutate process-global + * RNG state inside the host game. */ + uint32_t x = (uint32_t)(time(NULL) ^ (uintptr_t)out ^ (uintptr_t)&x); + if(!x) x = 0x9e3779b9u; + for(size_t i = 0; i < len; i++){ x ^= x<<13; x ^= x>>17; x ^= x<<5; out[i] = (unsigned char)x; } *olen = len; return 0; }