The code in src/drive.c that calls fread(3) treats its return (a size_t) as if it were the return from read(2) (a ssize_t).
For fread(3) the return value will never be negative. Instead, any time the return value is less than the amount requested, you need to check for both failure and EOF using ferror(3) and feof(3) respectively.