diff options
author | David Allsopp <david.allsopp@metastack.com> | 2021-10-15 11:47:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-15 11:47:50 +0100 |
commit | 87b02aee9d888a400f48ae488f59df92063b7f3b (patch) | |
tree | 324f51b9ddda3cc3729bf12a8536aa4f10cf3d51 | |
parent | 9417670a0d1c9a0f2eaa9b757f06a61ef11e6a56 (diff) | |
parent | dbb60dc4ee9a2519dba4f6937ca1110b3940be2b (diff) | |
download | ocaml-87b02aee9d888a400f48ae488f59df92063b7f3b.tar.gz |
Merge pull request #10702 from MisterDA/win32unix-cast-strictly-aligned-pointer-stat
Fix cast of more strictly aligned pointer
-rw-r--r-- | Changes | 4 | ||||
-rw-r--r-- | otherlibs/win32unix/stat.c | 12 |
2 files changed, 11 insertions, 5 deletions
@@ -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 ----------------------------- diff --git a/otherlibs/win32unix/stat.c b/otherlibs/win32unix/stat.c index 3748c9bc4c..23ad090853 100644 --- a/otherlibs/win32unix/stat.c +++ b/otherlibs/win32unix/stat.c @@ -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(); |