The existing code appears to use 'len_read' in several places where
'total_read' was intended. The function may work if the first 1 or 2
iterations of the loop read the requested 'len' bytes.
If the first two reads are "short" and a third read is done, the bytes
will be placed over previously read bytes in buf and more than 'len'
bytes may be read in total, though buf is never overrun.
This commit changes read_timed to
(1) correctly append short reads in buf
(2) correctly terminate when the sum of the short reads
equals the requested 'len' bytes
(3) return an error when read() returns -1 or 0
The function also depends on select() decrementing the timeout
structure, as it does on Linux. On other platforms, the exec_ms
returned is likely incorrect. This patch does not attempt to address
this issue.
* lto module clean-up
* step 1/3
* step 1/3 completed
* if tmp is ever made non-static
* parts 2 and 3 - autodictionary is complete
* variable map_size support
* variable map size: changed overlooked functions
* remove debug for autodict
* 64 bit alignment of map size
* fix review comments
* force 64 bit alignment on both sides
* typo
* Move afl-fuzz related env variables into afl_state_t
* Move the env variables assignment from fuzz_init and code Format
* Fix typo
* Remove redundant env variables from afl_env struct
* Rename function to read_afl_environment