}
uheader.magic = ntohl(uheader.magic);
- uheader.size = ntohl(uheader.size);
+ uheader.size = ntohs(uheader.size);
uheader.version.epoch = ntohl(uheader.version.epoch);
uheader.version.counter = ntohl(uheader.version.counter);
if (id == PRBADID)
continue;
else if (id) {
- int eid_s, id_s;
+ int id_s;
sgcount++;
/* in case the ids are large, convert to pure sign. */
if (id > 0)
id_s = 1;
else
id_s = -1;
- if (eid > 0)
- eid_s = 1;
- else
- eid_s = -1;
if (id_s > 0) {
fprintf(stderr,
"User can't be member of supergroup list\n");
{
afs_int32 head;
afs_int32 code;
- struct prentry c; /* continuation entry */
+ struct prentry te; /* next entry in owner chain */
afs_int32 na; /* next thread */
int ni;
afs_int32 eid = 0;
head = ntohl(cheader.orphan);
length = 0;
- for (na = head; na; na = ntohl(c.nextOwned)) {
+ for (na = head; na; na = ntohl(te.nextOwned)) {
code = ConvertDiskAddress(na, &ni);
if (code) {
fprintf(stderr, "Bad owned list ptr %d", na);
return PRDBBAD;
if (na != head) {
fprintf(stderr, "last block: \n");
- if (PrintEntryError(misc, na, &c, 4))
+ if (PrintEntryError(misc, na, &te, 4))
return PRDBBAD;
}
return 0;
}
- code = pr_Read(na, (char *)&c, sizeof(c));
+ code = pr_Read(na, (char *)&te, sizeof(te));
if (code)
return code;
length++;
+ if ((ntohl(te.flags) & PRTYPE) == PRCONT) {
+ fprintf(stderr, "Continuation entry found on owner chain\n");
+ if (e == 0)
+ fprintf(stderr, "walking orphan list");
+ else if (PrintEntryError(misc, ea, e, 2))
+ return PRDBBAD;
+ if (PrintEntryError(misc, na, &te, 4))
+ return PRDBBAD;
+ break;
+ }
if (map[ni] & MAP_OWNED) {
fprintf(stderr, "Entry on multiple owner chains\n");
if (e == 0)
fprintf(stderr, "walking orphan list");
else if (PrintEntryError(misc, ea, e, 2))
return PRDBBAD;
- if (PrintEntryError(misc, na, &c, 4))
+ if (PrintEntryError(misc, na, &te, 4))
return PRDBBAD;
break;
}
fprintf(stderr, "walking orphan list");
else if (PrintEntryError(misc, ea, e, 2))
return PRDBBAD;
- if (PrintEntryError(misc, na, &c, 4))
+ if (PrintEntryError(misc, na, &te, 4))
return PRDBBAD;
continue;
}
if (e) {
- if (ntohl(c.owner) != eid) {
+ if (ntohl(te.owner) != eid) {
fprintf(stderr, "Owner id mismatch\n");
goto abort;
}
- } else /* orphan */ if (c.owner) {
+ } else /* orphan */ if (te.owner) {
fprintf(stderr, "Orphan group owner not zero\n");
goto abort;
}
{
char *qs;
if (strpbrk(s, " \t")) {
- qs = (char *)malloc(strlen(s) + 3);
- strcpy(qs, "\"");
- strcat(qs, s);
- strcat(qs, "\"");
+ if (asprintf(&qs, "\"%s\"", s) < 0)
+ qs = "<<-OUT-OF-MEMORY->>";
} else
qs = s;
return qs;
}
if (misc->verbose)
printf("Database has %d entries\n", n);
- map = (char *)malloc(n);
- memset(map, 0, n);
+ map = calloc(1, n);
misc->nEntries = n;
if (misc->verbose) {
#else
n = ((misc->maxId > misc->maxForId) ? misc->maxId : misc->maxForId);
misc->idRange = n - misc->minId + 1;
- misc->idmap = (afs_int32 *) malloc(misc->idRange * sizeof(afs_int32));
+ misc->idmap = calloc(misc->idRange, sizeof(afs_int32));
if (!misc->idmap) {
afs_com_err(whoami, 0, "Unable to malloc space for max ids of %d",
misc->idRange);
code = -1;
goto abort;
}
- memset(misc->idmap, 0, misc->idRange * sizeof(misc->idmap[0]));
#endif /* SUPERGROUPS */
if (misc->verbose) {
setlinebuf(stdout);
- ts = cmd_CreateSyntax(NULL, WorkerBee, NULL, "PRDB check");
+ ts = cmd_CreateSyntax(NULL, WorkerBee, NULL, 0, "PRDB check");
cmd_AddParm(ts, "-database", CMD_SINGLE, CMD_REQUIRED, "ptdb_file");
cmd_AddParm(ts, "-uheader", CMD_FLAG, CMD_OPTIONAL,
"Display UBIK header");
idmapp = &idmap->idnext;
}
if (!idmap) {
- idmap = (struct idused *)malloc(sizeof *idmap);
+ idmap = calloc(1, sizeof *idmap);
if (!idmap) {
perror("idmap");
exit(1);
}
- memset(idmap, 0, sizeof idmap);
idmap->idstart = id & ~(IDCOUNT - 1);
idmap->idnext = *idmapp;
*idmapp = idmap;