Skip to content

Commit a58ecf7

Browse files
salo-deaVexu
authored andcommitted
Do not assume that FILE_BOTH_DIR_INFORMATION is correctly aligned
1 parent dc72f17 commit a58ecf7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/std/fs.zig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,9 @@ pub const IterableDir = struct {
749749
}
750750
}
751751

752-
const dir_info: *w.FILE_BOTH_DIR_INFORMATION = @ptrCast(@alignCast(&self.buf[self.index]));
752+
// While the official api docs guarantee FILE_BOTH_DIR_INFORMATION to be aligned properly
753+
// this may not always be the case (e.g. due to faulty VM/Sandboxing tools)
754+
const dir_info: *align(2) w.FILE_BOTH_DIR_INFORMATION = @ptrCast(@alignCast(&self.buf[self.index]));
753755
if (dir_info.NextEntryOffset != 0) {
754756
self.index += dir_info.NextEntryOffset;
755757
} else {

0 commit comments

Comments
 (0)