⬢ DragonFlyBSD Kernel Audit
DF-3143 / fix.diff
← back to finding ↓ download raw
--- a/sys/vfs/hpfs/hpfs_subr.c
+++ b/sys/vfs/hpfs/hpfs_subr.c
@@ -598,6 +598,11 @@
 	while(!(dep->de_flag & DE_END)) {
 		if(dep->de_flag & DE_DOWN) {
 			lsn = DE_DOWNLSN(dep);
 			level++;
+			if (level > 20) {
+				kprintf("hpfs_validateparent: B-tree too deep "
				    "(cycle?) at lsn 0x%x\n", lsn);
+				error = EINVAL;
+				goto failed;
+			}
 			goto dive;
 		}
@@ -612,6 +617,11 @@
 	if(dep->de_flag & DE_DOWN) {
 		dprintf(("[enddive] "));
 		lsn = DE_DOWNLSN(dep);
 		level++;
+		if (level > 20) {
+			kprintf("hpfs_validateparent: B-tree too deep "
			    "(cycle?) at lsn 0x%x\n", lsn);
+			error = EINVAL;
+			goto failed;
+		}
 		goto dive;
 	}