Currently sys_newstat's implementation is based on sys_stat64
This is inaccurate because sys_stat64 is expected to return a struct stat64 back to userland ref1ref2
Instead, sys_newstat is supposed to return a struct statref1ref2
This causes issues because the two structs have different definitions, and in practice causes errors in the loader. For example "LD_LIBRARY_PATH" environment variable does not work. I suspect https://github.com/trailofbits/manticore/issues/489 might be related as well but I have yet to test.
To fix this we can reuse the sys_newfstat implementation, which returns the correct struct stat structure to userland
newfstat
Currently sys_newfstat returns a structure based on the x86_64 version of struct statref1
This does not account for the different struct stat definition on 32-bit x86 ref1 (Notice the #ifdef)
Two changes in this PR
newstat
sys_newstat
's implementation is based onsys_stat64
sys_stat64
is expected to return astruct stat64
back to userland ref1 ref2sys_newstat
is supposed to return astruct stat
ref1 ref2sys_newfstat
implementation, which returns the correctstruct stat
structure to userlandnewfstat
sys_newfstat
returns a structure based on the x86_64 version ofstruct stat
ref1struct stat
definition on 32-bit x86 ref1 (Notice the#ifdef
)