Incorrect error handling for POSIX read and write
POSIX read
and write
return a value of the signed type ssize_t
, in particular, both return -1
on error. Neither _sion_file_read_posix
nor _sion_file_write_posix
check for this special value, assuming that like ANSI fread
and fwrite
only short counts will be returned and retry the operation. What makes things worse is that the return value of read
and write
are assigned to bread
and bwrote
, both of which are of unsigned type size_t
, meaning an ssize_t
value -1
will be converted to SIZE_MAX
which makes the arithmetic in the latter part of the retry loops adventurous (dataptr += bread
comes to mind).