Skip to content

Commit

Permalink
Fix nasa#36, handle read failure
Browse files Browse the repository at this point in the history
  • Loading branch information
zanzaben committed Mar 1, 2021
1 parent b02864b commit c3277d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cfe_ts_crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ int main(int argc, char **argv)
while (done == 0)
{
readSize = read(fd, buffer, 100);
fileCRC = CalculateCRC(buffer, readSize, fileCRC);
if (readSize < 0)
{
printf("\ncfe_ts_crc error: file read failed!\n");
exit(0);
}
fileCRC = CalculateCRC(buffer, (uint32)readSize, fileCRC);
fileSize += readSize;
if (readSize != 100)
done = 1;
Expand Down

0 comments on commit c3277d5

Please sign in to comment.