⬢ DragonFlyBSD Kernel Audit
DF-5554 / fix.diff
← back to finding ↓ download raw
--- a/sys/bus/cam/cam.c	2026-10-07 13:15:21.096445270 +0000
+++ b/sys/bus/cam/cam.c	2026-10-07 13:15:27.212366347 +0000
@@ -375,7 +375,7 @@
 void
 cam_calc_geometry(struct ccb_calc_geometry *ccg, int extended)
 {
-	uint32_t size_mb, secs_per_cylinder;
+	uint64_t size_mb, secs_per_cylinder;
 
 	if (ccg->block_size == 0) {
 		ccg->ccb_h.status = CAM_REQ_CMP_ERR;
@@ -394,8 +394,10 @@
 		ccg->heads = 64;
 		ccg->secs_per_track = 32;
 	}
-	secs_per_cylinder = ccg->heads * ccg->secs_per_track;
-	ccg->cylinders = ccg->volume_size / secs_per_cylinder;
+	secs_per_cylinder = (uint64_t)ccg->heads * ccg->secs_per_track;
+	secs_per_cylinder = ccg->volume_size / secs_per_cylinder;
+	ccg->cylinders = (secs_per_cylinder > (uint64_t)UINT32_MAX) ?
+	    UINT32_MAX : (u_int32_t)secs_per_cylinder;
 	ccg->ccb_h.status = CAM_REQ_CMP;
 }