hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 1530dabc54860804c1819aa5baa9d6b6a4cb78c2
parent c92881e5b8444d332635e95ea6ede13c2483ade9
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri, 13 Aug 2021 13:55:17 +0200

os::getenv: fix unbounded slice expression

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mos/+linux/environ.ha | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/os/+linux/environ.ha b/os/+linux/environ.ha @@ -37,7 +37,8 @@ export fn getenv(name: const str) (str | void) = { const name_b = strings::toutf8(name); for (let i = 0z; rt::envp[i] != null; i += 1) { const item = rt::envp[i]: *[*]u8; - const eq: size = match (bytes::index(item[..], '=': u32: u8)) { + const ln = strings::cstrlen(item: *char); + const eq: size = match (bytes::index(item[..ln], '=': u32: u8)) { void => abort("Environment violates System-V invariants"), i: size => i, };