{
register b1, b0;
b1 = iod_getc(iodp);
+ if (b1 == EOF)
+ return 0;
b0 = iod_getc(iodp);
+ if (b0 == EOF)
+ return 0;
*sp = (b1 << 8) | b0;
- return b0 != EOF;
+ return 1;
}
static int
{
afs_uint32 register b3, b2, b1, b0;
b3 = iod_getc(iodp);
+ if (b3 == EOF)
+ return 0;
b2 = iod_getc(iodp);
+ if (b2 == EOF)
+ return 0;
b1 = iod_getc(iodp);
+ if (b1 == EOF)
+ return 0;
b0 = iod_getc(iodp);
+ if (b0 == EOF)
+ return 0;
*lp = (((((b3 << 8) | b2) << 8) | b1) << 8) | b0;
- return b0 != EOF;
+ return 1;
}
static void
ReadString(register struct iod *iodp, register char *to, register int maxa)
{
register int c;
+ int first = 1;
+
+ *to = '\0';
+ if (maxa == 0)
+ return;
+
while (maxa--) {
- if ((*to++ = iod_getc(iodp)) == 0)
+ if ((*to++ = c = iod_getc(iodp)) == 0 || c == EOF)
break;
}
if (to[-1]) {
while ((c = iod_getc(iodp)) && c != EOF);
- to[-1] = 0;
+ to[-1] = '\0';
}
}
vcp->diskSize ? 0 : size - vcp->diskSize) >> vcp->logSize;
if (nVnodes > 0) {
Buf = (afs_int32 *) malloc(nVnodes * sizeof(afs_int32));
- if (Buf == NULL)
+ if (Buf == NULL) {
+ STREAM_CLOSE(afile);
+ FDH_CLOSE(fdP);
return 1;
+ }
memset((char *)Buf, 0, nVnodes * sizeof(afs_int32));
STREAM_SEEK(afile, offset = vcp->diskSize, 0);
while (1) {
register Volume *vp;
struct iod iod;
register struct iod *iodp = &iod;
- afs_int32 *b1 = 0, *b2 = 0;
- int s1 = 0, s2 = 0, delo = 0, tdelo;
+ afs_int32 *b1 = NULL, *b2 = NULL;
+ int s1 = 0, s2 = 0, delo = incremental, tdelo;
int tag;
iod_Init(iodp, call);
if (ReadVolumeHeader(iodp, &vol) == VOLSERREAD_DUMPERROR)
return VOLSERREAD_DUMPERROR;
- delo = ProcessIndex(vp, vLarge, &b1, &s1, 0);
+ if (!delo)
+ delo = ProcessIndex(vp, vLarge, &b1, &s1, 0);
if (!delo)
delo = ProcessIndex(vp, vSmall, &b2, &s2, 0);
if (delo) {
free((char *)b1);
if (b2)
free((char *)b2);
- b1 = b2 = 0;
+ b1 = b2 = NULL;
+ s1 = s2 = 0;
}
strncpy(vol.name, cookie->name, VOLSER_OLDMAXVOLNAME);
tag = iod_getc(iodp);
if (tag != D_VOLUMEHEADER)
break;
+
if (ReadVolumeHeader(iodp, &vol) == VOLSERREAD_DUMPERROR) {
error = VOLSERREAD_DUMPERROR;
goto out;
}
- tdelo = -1;
}
if (tag != D_DUMPEND || !ReadInt32(iodp, &endMagic)
|| endMagic != DUMPENDMAGIC) {
}
if (!delo) {
- ProcessIndex(vp, vLarge, &b1, &s1, 1);
- ProcessIndex(vp, vSmall, &b2, &s2, 1);
+ delo = ProcessIndex(vp, vLarge, &b1, &s1, 1);
+ if (!delo)
+ ProcessIndex(vp, vSmall, &b2, &s2, 1);
+ if (delo) {
+ error = VOLSERREAD_DUMPERROR;
+ goto clean;
+ }
}
clean:
if (!ReadInt32(iodp, (afs_uint32 *) & vnodeNumber))
break;
- ReadInt32(iodp, &vnode->uniquifier);
+ if (!ReadInt32(iodp, &vnode->uniquifier))
+ return VOLSERREAD_DUMPERROR;
while ((tag = iod_getc(iodp)) > D_MAX && tag != EOF) {
haveStuff = 1;
switch (tag) {
case 'l':
{
unsigned short tlc;
- ReadShort(iodp, &tlc);
+ if (!ReadShort(iodp, &tlc))
+ return VOLSERREAD_DUMPERROR;
vnode->linkCount = (signed int)tlc;
}
break;
case 'v':
- ReadInt32(iodp, &vnode->dataVersion);
+ if (!ReadInt32(iodp, &vnode->dataVersion))
+ return VOLSERREAD_DUMPERROR;
break;
case 'm':
- ReadInt32(iodp, &vnode->unixModifyTime);
+ if (!ReadInt32(iodp, &vnode->unixModifyTime))
+ return VOLSERREAD_DUMPERROR;
break;
case 's':
- ReadInt32(iodp, &vnode->serverModifyTime);
+ if (!ReadInt32(iodp, &vnode->serverModifyTime))
+ return VOLSERREAD_DUMPERROR;
break;
case 'a':
- ReadInt32(iodp, &vnode->author);
+ if (!ReadInt32(iodp, &vnode->author))
+ return VOLSERREAD_DUMPERROR;
break;
case 'o':
- ReadInt32(iodp, &vnode->owner);
+ if (!ReadInt32(iodp, &vnode->owner))
+ return VOLSERREAD_DUMPERROR;
break;
case 'g':
- ReadInt32(iodp, (afs_uint32 *) & vnode->group);
+ if (!ReadInt32(iodp, (afs_uint32 *) & vnode->group))
+ return VOLSERREAD_DUMPERROR;
break;
case 'b':{
unsigned short modeBits;
- ReadShort(iodp, &modeBits);
+ if (!ReadShort(iodp, &modeBits))
+ return VOLSERREAD_DUMPERROR;
vnode->modeBits = (unsigned int)modeBits;
break;
}
case 'p':
- ReadInt32(iodp, &vnode->parent);
+ if (!ReadInt32(iodp, &vnode->parent))
+ return VOLSERREAD_DUMPERROR;
break;
case 'A':
ReadByteString(iodp, (byte *) VVnodeDiskACL(vnode),
}
iod_ungetc(iodp, tag);
-
return 0;
}