Skip to content

Windows: Fix Iterator name buffer size not handling all possible file name components - #13153

Merged
andrewrk merged 6 commits into
ziglang:masterfrom
squeek502:iterator-filename-limits
Oct 30, 2022
Merged

Windows: Fix Iterator name buffer size not handling all possible file name components#13153
andrewrk merged 6 commits into
ziglang:masterfrom
squeek502:iterator-filename-limits

Conversation

@squeek502

@squeek502squeek502 commented Oct 14, 2022

Copy link
Copy Markdown
Member

Before this PR, the added test would have failed on Windows with the error found in #8268.

Fixes#8268.

@squeek502squeek502 changed the title Windows: Fix iterator name buffer size not handling all possible file name componentsWindows: Fix Iterator name buffer size not handling all possible file name componentsOct 14, 2022

@matu3bamatu3ba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments should be more conservative regarding guarantees, because the limits "generally work", but not in all cases (configuartions etc).
For general, portable + robust solutions, one must know the target systems limits and/or query the OS Kernel.

Please correct me, where I am wrong and which Kernels provide hard guarantees.

Comment threadlib/std/fs/test.zig
Comment threadlib/std/fs/test.zig Outdated
Comment threadlib/std/fs.zig Outdated
Comment threadlib/std/os/windows.zig
Comment threadlib/std/fs.zig Outdated
Comment threadlib/std/c/haiku.zig Outdated
Comment threadlib/std/fs.zig
Also add some NAME_MAX or equivalent definitions where necessary
… name components
Each u16 within a file name component can be encoded as up to 3 UTF-8 bytes, so we need to use MAX_NAME_BYTES to account for all possible UTF-8 encoded names.
Fixesziglang#8268
…orms
This is a slightly weird situation, because the 'real' value may depend on the host platform that the WASI is being executed on.
Make the test use the minimum length and set MAX_NAME_BYTES to the maximum so that:
- the test will work on any host platform
- *and* the MAX_NAME_BYTES will be able to hold the max file name component on any host platform
@squeek502
squeek502force-pushed the iterator-filename-limits branch from 4da34d5 to db80225CompareOctober 29, 2022 21:31
@andrewrk
andrewrk merged commit 209a0d2 into ziglang:masterOct 30, 2022
Sign up for freeto 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.

std.fs.Dir.Iterator cannot handle long file names on Windows

4 participants

@squeek502@marler8997@matu3ba@andrewrk