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 sys_stat size integer overflow #1157

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions src/hx/libs/std/Sys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,12 @@ void _hx_std_sys_rename( String path, String newname )
hx::Throw(HX_CSTRING("Could not rename"));
}

#define STATF(f) o->Add(HX_CSTRING(#f),(int)(s.st_##f))
#define STATF32(f) o->Add(HX_CSTRING(#f),(int)(s.st_##f))
#if defined(HXCPP_M64) || defined(HXCPP_ARM64)
#define STATF64(f) o->Add(HX_CSTRING(#f), static_cast<int64_t>(s.st_##f))
#else
#define STATF64 STATF32
#endif

/**
sys_stat : string -> {
Expand All @@ -429,7 +434,7 @@ void _hx_std_sys_rename( String path, String newname )
nlink => int,
rdev => int,
mode => int,
size => int
size => long
}
<doc>Run the [stat] command on the given file or directory.</doc>
**/
Expand Down Expand Up @@ -465,18 +470,17 @@ Dynamic _hx_std_sys_stat( String path )
return null();
hx::Anon o = hx::Anon_obj::Create();

STATF(gid);
STATF(uid);
STATF(atime);
STATF(mtime);
STATF(ctime);
STATF(dev);
STATF(ino);
STATF(mode);
STATF(nlink);
STATF(rdev);
STATF(size);
STATF(mode);
STATF32(gid);
STATF32(uid);
STATF32(atime);
STATF32(mtime);
STATF32(ctime);
STATF32(dev);
STATF32(ino);
STATF32(nlink);
STATF32(rdev);
STATF32(mode);
STATF64(size);

return o;
#endif
Expand Down