ptr = (char *)&value;
s = sizeof(value) - size;
- if (size < 0) {
- fprintf(stderr, "Too much data in afs_int32\n");
+ if (s < 0) {
+ fprintf(stderr, "Too much data for afs_int32\n");
return 0;
}
case 't':
dh->nDumpTimes = ntohl(readvalue(2)) >> 1;
+ if (dh->nDumpTimes > MAXDUMPTIMES) {
+ fprintf(stderr, "Too many dump times in header (%d > %d)\n",
+ dh->nDumpTimes, MAXDUMPTIMES);
+ dh->nDumpTimes = MAXDUMPTIMES;
+ }
for (i = 0; i < dh->nDumpTimes; i++) {
dh->dumpTimes[i].from = ntohl(readvalue(4));
dh->dumpTimes[i].to = ntohl(readvalue(4));
int fid;
int lfile;
afs_sfsize_t size, s;
+ ssize_t count;
/* Check if its vnode-file-link exists. If not,
* then the file will be an orphaned file.
/* Write the file out */
fid = open(filename, (O_CREAT | O_WRONLY | O_TRUNC), mode);
+ if (fid < 0) {
+ fprintf(stderr, "Open %s: Errno = %d\n", filename, errno);
+ goto open_fail;
+ }
size = vn.dataSize;
while (size > 0) {
s = (afs_int32) ((size > BUFSIZE) ? BUFSIZE : size);
code = fread(buf, 1, s, dumpfile);
- if (code > 0) {
- (void)write(fid, buf, code);
- size -= code;
- }
if (code != s) {
if (code < 0)
fprintf(stderr, "Code = %d; Errno = %d\n", code,
}
break;
}
+ if (code > 0) {
+ count = write(fid, buf, code);
+ if (count < 0) {
+ fprintf(stderr, "Count = %ld, Errno = %d\n",
+ (long)count, errno);
+ break;
+ } else if (count != code) {
+ fprintf(stderr, "Wrote %llu bytes out of %llu\n",
+ (afs_uintmax_t) count,
+ (afs_uintmax_t) code);
+ break;
+ }
+ size -= code;
+ }
}
close(fid);
if (size != 0) {
filename, fname);
}
+open_fail:
/* Remove the link to the file */
if (lfile) {
unlink(filename);
*/
snprintf(linkname, sizeof linkname, "%s" OS_DIRSEP "%s%d",
parentdir, AFILE, vn.vnode);
- len = readlink(linkname, fname, MAXNAMELEN);
+ len = readlink(linkname, fname, MAXNAMELEN - 1);
if (len < 0) {
snprintf(filename, sizeof filename, "%s" OS_DIRSEP "%s%d",
rootdir, OFILE, vn.vnode);
afs_int32 type, count, vcount;
DIR *dirP, *dirQ;
struct dirent *dirE, *dirF;
- char name[MAXNAMELEN];
- char thisdir[MAXPATHLEN], *t;
+ char name[2*MAXNAMELEN+1];
+ char thisdir[MAXPATHLEN+4], *t;
struct DumpHeader dh; /* Defined in dump.h */
#if 0/*ndef HAVE_GETCWD*/ /* XXX enable when autoconf happens */
extern char *getwd();
setlinebuf(stdout);
- ts = cmd_CreateSyntax(NULL, WorkerBee, NULL, "vldb check");
+ ts = cmd_CreateSyntax(NULL, WorkerBee, NULL, 0, "vldb check");
cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "restore dir");
cmd_AddParm(ts, "-extension", CMD_SINGLE, CMD_OPTIONAL, "name extension");