Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Jun 2019 20:11:52 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r349438 - head/sbin/dhclient
Message-ID:  <201906262011.x5QKBq5e065476@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Wed Jun 26 20:11:52 2019
New Revision: 349438
URL: https://svnweb.freebsd.org/changeset/base/349438

Log:
  Avoid a divide-by-zero when bad checksum counters overflow.
  
  A mixture of IP or UDP packets with valid and invalid checksum could
  cause {ip,udp}_packets_bad_checksum to wrap around to 0, resulting
  in a division by zero.
  
  This is packet.c rev. 1.27 from OpenBSD.
  
  admbugs:	552
  Obtained from:	OpenBSD
  MFC after:	3 days

Modified:
  head/sbin/dhclient/packet.c

Modified: head/sbin/dhclient/packet.c
==============================================================================
--- head/sbin/dhclient/packet.c	Wed Jun 26 20:07:16 2019	(r349437)
+++ head/sbin/dhclient/packet.c	Wed Jun 26 20:11:52 2019	(r349438)
@@ -183,7 +183,7 @@ decode_udp_ip_header(unsigned char *buf, int bufix, st
 	ip_packets_seen++;
 	if (wrapsum(checksum(buf + bufix, ip_len, 0)) != 0) {
 		ip_packets_bad_checksum++;
-		if (ip_packets_seen > 4 &&
+		if (ip_packets_seen > 4 && ip_packets_bad_checksum != 0 &&
 		    (ip_packets_seen / ip_packets_bad_checksum) < 2) {
 			note("%d bad IP checksums seen in %d packets",
 			    ip_packets_bad_checksum, ip_packets_seen);
@@ -235,7 +235,7 @@ decode_udp_ip_header(unsigned char *buf, int bufix, st
 	udp_packets_seen++;
 	if (usum && usum != sum) {
 		udp_packets_bad_checksum++;
-		if (udp_packets_seen > 4 &&
+		if (udp_packets_seen > 4 && udp_packets_bad_checksum != 0 &&
 		    (udp_packets_seen / udp_packets_bad_checksum) < 2) {
 			note("%d bad udp checksums in %d packets",
 			    udp_packets_bad_checksum, udp_packets_seen);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906262011.x5QKBq5e065476>