Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cast of more strictly aligned pointer #10702

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ Working version
- #10693: Fix ident collision in includemod
(Leo White, review by Matthew Ryan)

- #10702: Fix cast of more strictly aligned pointer in win32unix
implementation of stat
(Antonin Décimo, review by David Allsopp)

OCaml 4.13 maintenance branch
-----------------------------

Expand Down
12 changes: 7 additions & 5 deletions otherlibs/win32unix/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,17 @@ static int safe_do_stat(int do_lstat, int use_64, wchar_t* path, HANDLE fstat, _
* reparse point allows a POSIX-compatible value to be returned in
* st_size
*/
char buffer[16384];
DWORD read;
REPARSE_DATA_BUFFER* point;
union {
char raw[16384];
REPARSE_DATA_BUFFER point;
} buffer;

caml_enter_blocking_section();
if (DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer, 16384, &read, NULL)) {
if (((REPARSE_DATA_BUFFER*)buffer)->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
if (DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, NULL, 0, &buffer.point, sizeof(buffer.raw), &read, NULL)) {
if (buffer.point.ReparseTag == IO_REPARSE_TAG_SYMLINK) {
is_symlink = do_lstat;
res->st_size = ((REPARSE_DATA_BUFFER*)buffer)->SymbolicLinkReparseBuffer.SubstituteNameLength / 2;
res->st_size = buffer.point.SymbolicLinkReparseBuffer.SubstituteNameLength / 2;
}
}
caml_leave_blocking_section();
Expand Down