--- lib/md5.c.old 2003-02-17 05:55:20.000000000 +0000 +++ lib/md5.c 2003-02-17 05:56:11.000000000 +0000 @@ -156,13 +156,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 still be at EOF + even if fread() returns > 0 + */ + if (n == 0 || feof(stream)) break; /* Process buffer with BLOCKSIZE bytes. Note that