handleit(struct cmd_syndesc *as, void *arock)
{
int w, old, new, rc, dump = 0, fromv = 0;
+ ssize_t count;
+
char ubik[80]; /* space for some ubik header */
union {
struct vlheader_1 header1;
}
/* Read the version */
- lseek(old, 64, L_SET);
- read(old, &fromv, sizeof(int));
+ if (lseek(old, 64, L_SET) == (off_t)-1) {
+ perror(pn);
+ exit(-1);
+ }
+ count = read(old, &fromv, sizeof(int));
+ if (count < 0) {
+ perror(pn);
+ exit(-1);
+ } else if (count != sizeof(int)) {
+ fprintf(stderr, "%s: Premature EOF reading database version.\n", pn);
+ exit(-1);
+ }
fromv = ntohl(fromv);
if ((fromv < 1) || (fromv > 4)) {
fprintf(stderr, "%s", pn);
}
/* Sequentially read the database converting the entries as we go */
- lseek(old, 0, L_SET);
- read(old, ubik, 64);
+ if (lseek(old, 0, L_SET) == (off_t)-1) {
+ perror(pn);
+ exit(-1);
+ }
+ count = read(old, ubik, 64);
+ if (count < 0) {
+ perror(pn);
+ exit(-1);
+ } else if (count != 64) {
+ fprintf(stderr, "%s: Premature EOF reading database header.\n", pn);
+ exit(-1);
+ }
readheader(old, fromv, &oldheader);
if (fromv == 1) {
dbsize = ntohl(oldheader.header1.vital_header.eofPtr);