(Although it's quite a corner case, for the case of integrity of the code,) translate_sys2libc_fd_int should be fixed.
- Its API has the argument as type int, which is not right to represent the HANDLE of Windows
- the semantics here is that the value can be: 0, 1, 2 to represent standard input, output, and error, or else HANDLE
- It works now (most of the case)
- it works when the value of HANDLE can be represented in 31-bit positive integer
- It may fail (in a corner case)
- Even if Windows will keep the value of HANDLE within 32-bit, it has a possibility that the value may be negative in 32-bit integer
- in this case, it may fail in the conversion to 64-bit representation
- when the conversion is by sign extension to 64-bit, it fails
- when the conversion is by zero extension to 64-bit, it is OK
- in this case, it may fail in the conversion to 64-bit representation
- Even if Windows will keep the value of HANDLE within 32-bit, it has a possibility that the value may be negative in 32-bit integer