From 0f608183d9ad9595f6052ddafc8a5fedb82d7fc3 Mon Sep 17 00:00:00 2001 From: Uzair Aftab Date: Thu, 15 Oct 2026 20:22:10 +0200 Subject: [PATCH] linux: don't count the last environ read twice Platform_getProcessEnv() reads /proc/PID/environ in a loop that adds each fread() result to size as it goes. After the loop it added the last result once more, so whenever the environment ended partway through the buffer, the block it returned was too long by that many bytes. EnvScreen then parsed the uninitialised heap memory past the real data as more variables, which shows up as junk entries, often rendered as U+FFFD, on the environment screen. The loop already counts every byte it reads, so the extra addition is simply removed. Found while fuzzing htop's UI with Bombadil. --- linux/Platform.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/linux/Platform.c b/linux/Platform.c index dd4121e8e6..9268006dc4 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -545,8 +545,6 @@ char* Platform_getProcessEnv(pid_t pid) { return NULL; } - size += bytes; - env = xRealloc(env, size + 2); env[size] = '\0';