handle empty files as bad magic, not read errors

CVS patchset: 1891
CVS date: 1997/11/03 20:17:45
This commit is contained in:
ewt 1997-11-03 20:17:45 +00:00
parent 727d6480b1
commit d63fd08403
1 changed files with 6 additions and 1 deletions

View File

@ -2,6 +2,7 @@
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "errno.h"
@ -29,13 +30,17 @@ static int readPackageHeaders(int fd, struct rpmlead * leadPtr,
struct oldrpmlead * oldLead;
int_8 arch;
int isSource;
struct stat sb;
hdr = hdrPtr ? hdrPtr : &hdrBlock;
lead = leadPtr ? leadPtr : &leadBlock;
oldLead = (struct oldrpmlead *) lead;
if (readLead(fd, lead)) {
fstat(fd, &sb);
if (sb.st_size < 4) return 1;
if ((rc = readLead(fd, lead))) {
return 2;
}