aboutsummaryrefslogtreecommitdiff
path: root/lib/std/fs.zig
diff options
context:
space:
mode:
authorsalo-dea <46715729+salo-dea@users.noreply.github.com>2023-11-10 17:04:08 +0100
committerVeikka Tuominen <git@vexu.eu>2023-11-21 15:21:41 +0200
commita58ecf7b090f744975cf3816204fe0e891ff73ba (patch)
tree511c7404f80cb92609076604df37a70bd9b6e7f4 /lib/std/fs.zig
parentdc72f17d8026c73acda90f107690c14327173c5f (diff)
downloadzig-a58ecf7b090f744975cf3816204fe0e891ff73ba.tar.gz
zig-a58ecf7b090f744975cf3816204fe0e891ff73ba.zip
Do not assume that FILE_BOTH_DIR_INFORMATION is correctly aligned
Diffstat (limited to 'lib/std/fs.zig')
-rw-r--r--lib/std/fs.zig4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/std/fs.zig b/lib/std/fs.zig
index fd8116edaa..97d689484e 100644
--- a/lib/std/fs.zig
+++ b/lib/std/fs.zig
@@ -749,7 +749,9 @@ pub const IterableDir = struct {
}
}
- const dir_info: *w.FILE_BOTH_DIR_INFORMATION = @ptrCast(@alignCast(&self.buf[self.index]));
+ // While the official api docs guarantee FILE_BOTH_DIR_INFORMATION to be aligned properly
+ // this may not always be the case (e.g. due to faulty VM/Sandboxing tools)
+ const dir_info: *align(2) w.FILE_BOTH_DIR_INFORMATION = @ptrCast(@alignCast(&self.buf[self.index]));
if (dir_info.NextEntryOffset != 0) {
self.index += dir_info.NextEntryOffset;
} else {