Reproduced problem
env_get reads at most 32,768 bytes into its internal environment buffer. The Linux provider performs one read of /proc/self/environ. If that read ends in the middle of an entry, the high-level parser treats the buffer boundary as the end of a complete value and returns success.
With an environment containing only WAVE_AUDIT_VALUE set to 40,000 x characters, this program prints count=32751, despite a destination large enough for the full value:
import("std::env::environ")::{env_get};
fun main() -> i32 {
var output: array<u8, 50000>;
var count: i64 = env_get("WAVE_AUDIT_VALUE", &output[0], 50000);
println("count={}", count);
return 0;
}
After building it as long_env, run the binary with a controlled environment:
import subprocess
subprocess.run(["/absolute/path/to/long_env"],
env={"WAVE_AUDIT_VALUE": "x" * 40000}, check=True)
Scope and acceptance
Start with std/env/environ.wave:67-104 and std/sys/linux/{amd64,arm64,riscv64,loong64}/env.wave. Related #427 covers general environment boundary tests; #423 and #424 cover presence checks and integer overflow. This issue is specifically the incomplete source-read bug.
Audited on canonical master 0c67f4cc0c3946cbf708c11ef79db927ec8f054e (same source tree as #502 head). Executable reproductions used Fedora Linux amd64, Wave 0.2.1-pre-beta-dev, LLVM 21.1.8.
Reproduced problem
env_getreads at most 32,768 bytes into its internal environment buffer. The Linux provider performs one read of/proc/self/environ. If that read ends in the middle of an entry, the high-level parser treats the buffer boundary as the end of a complete value and returns success.With an environment containing only
WAVE_AUDIT_VALUEset to 40,000xcharacters, this program printscount=32751, despite a destination large enough for the full value:After building it as
long_env, run the binary with a controlled environment:Scope and acceptance
Start with
std/env/environ.wave:67-104andstd/sys/linux/{amd64,arm64,riscv64,loong64}/env.wave. Related #427 covers general environment boundary tests; #423 and #424 cover presence checks and integer overflow. This issue is specifically the incomplete source-read bug.Audited on canonical master
0c67f4cc0c3946cbf708c11ef79db927ec8f054e(same source tree as #502 head). Executable reproductions used Fedora Linux amd64, Wave0.2.1-pre-beta-dev, LLVM 21.1.8.