struct DirHeader *dhp;
struct DirEntry *ep;
int code = 0;
+ int elements;
dhp = (struct DirHeader *)DRead(dir, 0);
if (!dhp)
for (i = 0; i < NHASHENT; i++) {
/* For each hash chain, enumerate everyone on the list. */
num = ntohs(dhp->hashTable[i]);
- while (num != 0) {
+ elements = 0;
+ while (num != 0 && elements < BIGMAXPAGES * EPP) {
+ elements++;
+
/* Walk down the hash table list. */
code = GetVerifiedBlob(dir, num, &ep);
if (code)
struct DirHeader *dhp;
struct DirEntry *ep;
int code;
+ int elements;
dhp = (struct DirHeader *)DRead(dir, 0);
if (!dhp)
for (i = 0; i < NHASHENT; i++) {
/* For each hash chain, enumerate everyone on the list. */
num = ntohs(dhp->hashTable[i]);
- while (num != 0) {
+ elements = 0;
+ while (num != 0 && elements < BIGMAXPAGES * EPP) {
+ elements++;
/* Walk down the hash table list. */
code = GetVerifiedBlob(dir, num, &ep);
if (code)
struct DirHeader *dhp;
unsigned short *lp;
struct DirEntry *tp;
+ int elements;
i = DirHash(ename);
dhp = (struct DirHeader *)DRead(dir, 0);
}
lp = &(dhp->hashTable[i]);
- while (1) {
+ elements = 0;
+ /* Detect circular hash chains. Absolute max size of a directory */
+ while (elements < BIGMAXPAGES * EPP) {
+ elements++;
+
/* Look at each hash conflict entry. */
if (!strcmp(ename, tp->name)) {
/* Found our entry. */
*previtem = lp;
return tp;
}
+
DRelease(lp, 0);
lp = &(tp->next);
- if (tp->next == 0) {
- /* The end of the line */
- DRelease(lp, 0); /* Release all locks. */
- return 0;
- }
+ if (tp->next == 0)
+ break;
+
GetVerifiedBlob(dir, (u_short) ntohs(tp->next), &tp);
- if (tp == NULL) {
- DRelease(lp, 0);
- return NULL;
- }
+ if (tp == NULL)
+ break;
}
+ DRelease(lp, 0);
+ return NULL;
}
static struct DirEntry *
struct DirHeader *dhp;
unsigned short *lp;
struct DirEntry *tp;
+ int elements;
dhp = (struct DirHeader *) DRead(dir,0);
if (!dhp) return 0;
DRelease(dhp, 0);
return 0;
}
- while(tp) {
+ elements = 0;
+ while(tp && elements < BIGMAXPAGES * EPP) {
+ elements++;
if (vnode == ntohl(tp->fid.vnode)
&& unique == ntohl(tp->fid.vunique)) {
DRelease(dhp, 0);