tritondse icon indicating copy to clipboard operation
tritondse copied to clipboard

getenv Routine causes unhandled exception

Open jordan9001 opened this issue 2 years ago • 1 comments
trafficstars

The routine rtn_getenv can return a value of type str.

(Pdb) p type(host_env_val)
<class 'str'>

But __handle_external_return expects the return value to be either an integer or an Expression. When calling write_symbolic_register an exception will be thrown when trying to pass the string to newSymbolicExpression

Logic should be added to have rtn_getenv to return a pointer to the string. The environment may need to be populated on the stack during process creation, as it is with a real process.

jordan9001 avatar Oct 31 '23 20:10 jordan9001

Hello @jordan9001. The current implementation of getenv is indeed faulty as it return a string while it should not. Indeed populating the stack at the begining of the execution would be to most accurate modeling. Another option is to allocate a buffer for the string and returning the pointer to it.

A nice implementation would also take to opportunity to symbolize the returned string if it is part of the input (and returning the concrete one otherwise).

Implementing these routines is an endless work and I am lacking time. Feel free to submit a PR, we would be bery happy to review it and to merge it.

RobinDavid avatar Nov 02 '23 22:11 RobinDavid