DragonFlyBSD Kernel Audit
DF-0287 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/netproto/802_11/wlan/ieee80211_mesh.c b/sys/netproto/802_11/wlan/ieee80211_mesh.c
--- a/sys/netproto/802_11/wlan/ieee80211_mesh.c
+++ b/sys/netproto/802_11/wlan/ieee80211_mesh.c
@@ -3364,6 +3364,11 @@
 
 	/* Time to transmit a frame */
 	rate = ni->ni_txrate;
+	/* A freshly discovered neighbour may have ni_txrate == 0, which
+	 * would divide-by-zero in nbits/rate (and in
+	 * ieee80211_compute_duration() below). */
+	if (rate == 0)
+		return IEEE80211_MESHLMETRIC_INITIALVAL;
 	overhead = ieee80211_compute_duration(ic->ic_rt,
 	    ifp->if_mtu + IEEE80211_MESH_MAXOVERHEAD, rate, 0) << M_BITS;
 	/* Error rate in percentage */