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

Unix.LargeFile.fstat cannot report size over 32bits on Win32 #4735

Closed
vicuna opened this issue Feb 28, 2009 · 1 comment
Closed

Unix.LargeFile.fstat cannot report size over 32bits on Win32 #4735

vicuna opened this issue Feb 28, 2009 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Feb 28, 2009

Original bug ID: 4735
Reporter: gildor
Status: closed (set by @xavierleroy on 2009-03-28T16:40:12Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 3.10.2
Fixed in version: 3.11.1+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

In file otherlibs/win32unix/stat.c

CAMLprim value unix_fstat_64(value handle)
{
int ret;
struct _stati64 buf;

ret = _fstati64(win_CRT_fd_of_filedescr(handle), &buf);
if (ret == -1) uerror("fstat", Nothing);
if (buf.st_size > Max_long) {
win32_maperr(ERROR_ARITHMETIC_OVERFLOW);
uerror("fstat", Nothing);
}
return stat_aux(1, &buf);
}

The test with Max_long is a copy an paste from unix_fstat. It should be rewritten as is:

CAMLprim value unix_fstat_64(value handle)
{
int ret;
struct _stati64 buf;

ret = _fstati64(win_CRT_fd_of_filedescr(handle), &buf);
if (ret == -1) uerror("fstat", Nothing);
return stat_aux(1, &buf);
}

This allow to report size over 31 bits long.

@vicuna
Copy link
Author

vicuna commented Mar 28, 2009

Comment author: @xavierleroy

Fixed as suggested in 3.11 branch, will go in 3.11.1.

@vicuna vicuna closed this as completed Mar 28, 2009
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant