fix coverity tell < 0 and store fread bytes issues