DragonFlyBSD Kernel Audit
DF-0106 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/sys/disklabel32.h b/sys/sys/disklabel32.h
--- a/sys/sys/disklabel32.h
+++ b/sys/sys/disklabel32.h
@@ -154,7 +154,7 @@
 	u_int16_t sum = 0;
 
 	start = (u_int16_t *)lp;
-	end = (u_int16_t *)&lp->d_partitions[lp->d_npartitions];
+	end = (u_int16_t *)&lp->d_partitions[MIN(lp->d_npartitions, MAXPARTITIONS32)];
 	while (start < end)
 		sum ^= *start++;
 	return (sum);