Skip to content

fix(stdlib): Correct path bounds checks in wasi/File module - #2395

Merged
ospencer merged 1 commit into
grain-lang:oscar/gc-rebasedfrom
Kara-Zor-El:Kara-Zor-El/filesystem-fixes
Sep 2, 2026
Merged

ospencer merged 1 commit into
grain-lang:oscar/gc-rebasedfrom
Kara-Zor-El:Kara-Zor-El/filesystem-fixes

Conversation

@Kara-Zor-El

@Kara-Zor-El Kara-Zor-El commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

It was noticed that Fs.exists was throwing an uncaught error and while looking into that error it was also noticed that doing --dir=. instead of --dir=./ caused another similar uncaught error.

The problem relating to Fs.exists stemmed from a couple of out of bounds reads that were solved by checking if we are past the boundary of the string before rather than after, this bug existed before the gc work however as we are now using gc arrays which are bounds checked the error surfaced.

The problem with the preopens stemmed from stripPrefix we were mistaking checking for ./ before . which led to an overread similar to before this error never surfaced before the gc work as linear memory isn't bounds checked.

@spotandjake spotandjake changed the title fix(stdlib): Fix bounds checking in Fs fix(stdlib): Correct path bounds checks in wasi/File module Jul 10, 2026
@ospencer

Copy link
Copy Markdown
Member

Are there any tests we can add here?

@spotandjake

Copy link
Copy Markdown
Member

Are there any tests we can add here?

I'm pretty sure this is covered by our issue to enable fs.test.gr

@ospencer
ospencer merged commit f1e8ec8 into grain-lang:oscar/gc-rebased Sep 2, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants