--- lib/sha.c.old 2003-02-17 06:02:52.000000000 +0000 +++ lib/sha.c 2003-02-17 06:03:24.000000000 +0000 @@ -142,13 +142,17 @@ n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); sum += n; + if (feof(stream)) + break; } while (sum < BLOCKSIZE && n != 0); if (n == 0 && ferror (stream)) return 1; - /* If end of file is reached, end the loop. */ - if (n == 0) + /* If end of file is reached, end the loop. We can be at EOF + even if fread() > 0 + */ + if (n == 0 || feof(stream)) break; /* Process buffer with BLOCKSIZE bytes. Note that