Skip to content

Commit

Permalink
Merge pull request #10702 from MisterDA/win32unix-cast-strictly-align…
Browse files Browse the repository at this point in the history
…ed-pointer-stat

Fix cast of more strictly aligned pointer
  • Loading branch information
dra27 committed Oct 15, 2021
2 parents 9417670 + dbb60dc commit 87b02ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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

0 comments on commit 87b02ae

Please sign in to comment.