Skip to contentSkip to conversation

DCCP: Divide by zero fix

PATCH New Ian McDonald 1 participant 1 message Feb 17, 2006 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 DCCP: Divide by zero fix

In rare circumstances 0 is returned by dccp_li_hist_calc_i_mean which leads to a divide by zero in ccid3_hc_rx_packet_recv. Explicitly check for zero return now. Update copyright notice at same time.

Found by Arnaldo

----

net/dccp/ccids/ccid3.c +5 -4
index 165fc40..fb4db88 100644
@@ -2,7 +2,7 @@
  *  net/dccp/ccids/ccid3.c
  *
  *  Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand.
- *  Copyright (c) 2005 Ian McDonald <[email protected]>
+ *  Copyright (c) 2005-6 Ian McDonald <[email protected]>
  *
  *  An implementation of the DCCP protocol
  *
@@ -925,7 +925,7 @@ static void ccid3_hc_rx_packet_recv(stru
 	struct dccp_rx_hist_entry *packet;
 	struct timeval now;
 	u8 win_count;
-	u32 p_prev, r_sample, t_elapsed;
+	u32 p_prev, r_sample, t_elapsed, i_mean;
 	int ins;
 
 	BUG_ON(hcrx = NULL ||
@@ -1025,9 +1025,11 @@ static void ccid3_hc_rx_packet_recv(stru
 	p_prev = hcrx->ccid3hcrx_p;
 	
 	/* Calculate loss event rate */
-	if (!list_empty(&hcrx->ccid3hcrx_li_hist))
+	if (!list_empty(&hcrx->ccid3hcrx_li_hist)) {
+		i_mean = dccp_li_hist_calc_i_mean(&hcrx->ccid3hcrx_li_hist);
+		if (i_mean)
 		/* Scaling up by 1000000 as fixed decimal */
-		hcrx->ccid3hcrx_p = 1000000 /

dccp_li_hist_calc_i_mean(&hcrx->ccid3hcrx_li_hist);
+ hcrx->ccid3hcrx_p = 1000000 / i_mean;

if (hcrx->ccid3hcrx_p > p_prev) {
ccid3_hc_rx_send_feedback(sk);