use timedRead() instead of read()

CVS patchset: 1096
CVS date: 1996/10/15 03:15:30
This commit is contained in:
ewt 1996-10-15 03:15:30 +00:00
parent 22f79c11fa
commit e106025673
3 changed files with 26 additions and 16 deletions

View File

@ -11,6 +11,7 @@
#include "oldheader.h"
#include "rpmerr.h"
#include "rpmlib.h"
#include "tread.h"
/* This *can't* read 1.0 headers -- it needs 1.1 (w/ group and icon fields)
or better. I'd be surprised if any 1.0 headers are left anywhere anyway.
@ -42,7 +43,7 @@ char * oldhdrReadFromStream(int fd, struct oldrpmHeader * header) {
unsigned int archiveOffset;
unsigned int groupLength;
if (read(fd, &lit, sizeof(lit)) != sizeof(lit)) {
if (timedRead(fd, &lit, sizeof(lit)) != sizeof(lit)) {
return strerror(errno);
}
@ -86,7 +87,7 @@ char * oldhdrReadFromStream(int fd, struct oldrpmHeader * header) {
return "out of memory";
}
if (read(fd, header->group, groupLength) != groupLength) {
if (timedRead(fd, header->group, groupLength) != groupLength) {
oldhdrFree(header);
return strerror(errno);
}
@ -104,7 +105,8 @@ char * oldhdrReadFromStream(int fd, struct oldrpmHeader * header) {
free(header->icon);
return "out of memory";
}
if (read(fd, header->icon, header->iconLength) != header->iconLength) {
if (timedRead(fd, header->icon, header->iconLength) !=
header->iconLength) {
oldhdrFree(header);
return strerror(errno);
}
@ -114,21 +116,21 @@ char * oldhdrReadFromStream(int fd, struct oldrpmHeader * header) {
}
while (bytesRead < specOffset) {
if (read(fd, &ch, 1) != 1) {
if (timedRead(fd, &ch, 1) != 1) {
oldhdrFree(header);
return strerror(errno);
}
bytesRead++;
}
if (read(fd, header->spec, header->specLength) != header->specLength) {
if (timedRead(fd, header->spec, header->specLength) != header->specLength) {
oldhdrFree(header);
return strerror(errno);
}
bytesRead += header->specLength;
while (bytesRead < archiveOffset) {
if (read(fd, &ch, 1) != 1) {
if (timedRead(fd, &ch, 1) != 1) {
oldhdrFree(header);
return strerror(errno);
}

View File

@ -11,6 +11,7 @@
#include "rpmerr.h"
#include "rpmlead.h"
#include "tread.h"
/* The lead needs to be 8 byte aligned */
@ -37,7 +38,7 @@ int writeLead(int fd, struct rpmlead *lead)
int readLead(int fd, struct rpmlead *lead)
{
if (read(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
if (timedRead(fd, lead, sizeof(*lead)) != sizeof(*lead)) {
error(RPMERR_READERROR, "read failed: %s (%d)", strerror(errno),
errno);
return 1;

View File

@ -19,11 +19,12 @@
#include <fcntl.h>
#include <strings.h>
#include "signature.h"
#include "md5.h"
#include "rpmlib.h"
#include "rpmlead.h"
#include "rpmerr.h"
#include "signature.h"
#include "tread.h"
typedef int (*md5func)(char * fn, unsigned char * digest);
@ -77,7 +78,7 @@ int readSignature(int fd, Header *header, short sig_type)
case RPMSIG_PGP262_1024:
message(MESS_DEBUG, "Old PGP signature\n");
/* These are always 256 bytes */
if (read(fd, buf, 256) != 256) {
if (timedRead(fd, buf, 256) != 256) {
return 1;
}
if (header) {
@ -111,7 +112,7 @@ int readSignature(int fd, Header *header, short sig_type)
return 1;
}
if (pad) {
if (read(fd, buf, pad) != pad) {
if (timedRead(fd, buf, pad) != pad) {
freeHeader(h);
return 1;
}
@ -238,7 +239,7 @@ static int makePGPSignature(char *file, void **sig, int_32 *size,
*sig = malloc(*size);
fd = open(sigfile, O_RDONLY);
if (read(fd, *sig, *size) != *size) {
if (timedRead(fd, *sig, *size) != *size) {
unlink(sigfile);
close(fd);
free(*sig);
@ -259,13 +260,19 @@ static int checkSize(int fd, int size, int sigsize)
struct stat statbuf;
fstat(fd, &statbuf);
headerArchiveSize = statbuf.st_size - sizeof(struct rpmlead) - sigsize;
message(MESS_DEBUG, "sigsize : %d\n", sigsize);
message(MESS_DEBUG, "Header + Archive: %d\n", headerArchiveSize);
message(MESS_DEBUG, "expected size : %d\n", size);
if (S_ISREG(statbuf.st_mode)) {
headerArchiveSize = statbuf.st_size - sizeof(struct rpmlead) - sigsize;
return size - headerArchiveSize;
message(MESS_DEBUG, "sigsize : %d\n", sigsize);
message(MESS_DEBUG, "Header + Archive: %d\n", headerArchiveSize);
message(MESS_DEBUG, "expected size : %d\n", size);
return size - headerArchiveSize;
} else {
message(MESS_DEBUG, "file is not regular -- skipping size check\n");
return 0;
}
}
int verifySignature(char *file, int_32 sigTag, void *sig, int count,