diff --git a/djpeg.c b/djpeg.c index e4e8a621..589c5805 100644 --- a/djpeg.c +++ b/djpeg.c @@ -566,7 +566,7 @@ main (int argc, char **argv) exit(EXIT_FAILURE); } nbytes = JFREAD(input_file, &inbuffer[insize], INPUT_BUF_SIZE); - if (nbytes < 0) { + if (nbytes < INPUT_BUF_SIZE && ferror(input_file)) { if (file_index < argc) fprintf(stderr, "%s: can't read from %s\n", progname, argv[file_index]); diff --git a/tjbench.c b/tjbench.c index 105a4cce..1f88e133 100644 --- a/tjbench.c +++ b/tjbench.c @@ -475,7 +475,7 @@ void dodecomptest(char *filename) if((file=fopen(filename, "rb"))==NULL) _throwunix("opening file"); - if(fseek(file, 0, SEEK_END)<0 || (srcsize=ftell(file))<0) + if(fseek(file, 0, SEEK_END)<0 || (srcsize=ftell(file))==(unsigned long)-1) _throwunix("determining file size"); if((srcbuf=(unsigned char *)malloc(srcsize))==NULL) _throwunix("allocating memory");