[nagiosplug] check_dhcp: Fix handling of "pad" options

"Nagios Plugin Development" <[email protected]> Wed, 13 Jun 2012 12:00:18 +0000
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
 Module: nagiosplug
 Branch: master
 Commit: f091d59e0f9abec9304d9d230fafc2dec001baba
 Author: Holger Weiss <[email protected]>
   Date: Wed Jun 13 12:36:42 2012 +0200
    URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=f091d59

check_dhcp: Fix handling of "pad" options

Don't let "pad" options[*] terminate the parsing of DHCP options.  This
bug was triggered by using check_dhcp against Windows 2003 DHCP servers
(see #3503921).

[*] Cf. RFC 2132, 3.1.

---

 NEWS                      |    1 +
 plugins-root/check_dhcp.c |    7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 7452a6b..b138084 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,7 @@ This file documents the major additions and syntax changes between releases.
 	Fix segfault in check_host when hostname returns multiple IP addresses (Sebastian Harl)
 	Fix check_smtp and check_tcp where duplicate messages were displayed for certificate errors
 	Fix check_ping's parsing of the output of Debian's ping6(1) implementation (#1894850 - Matej Vela)
+	Fix a check_dhcp bug which was triggered by using it to check Windows 2003 DHCP servers (#3503921)
 	Disable RFC4507 support, to work around SSL negotiation issues with (at least) some Tomcat versions
 
 1.4.15 27th July 2010
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index 2a1875c..ac89274 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -839,8 +839,7 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
 	/* process all DHCP options present in the packet */
 	for(x=4;x<MAX_DHCP_OPTIONS_LENGTH;){
 
-		/* end of options (0 is really just a pad, but bail out anyway) */
-		if((int)offer_packet->options[x]==-1 || (int)offer_packet->options[x]==0)
+		if((int)offer_packet->options[x]==-1)
 			break;
 
 		/* get option type */
@@ -872,7 +871,9 @@ int add_dhcp_offer(struct in_addr source,dhcp_packet *offer_packet){
 			}
 
 		/* skip option data we're ignoring */
-		if(option_type!=DHCP_OPTION_REBINDING_TIME)
+		if(option_type==0) /* "pad" option, see RFC 2132 (3.1) */
+			x+=1;
+		else
 			x+=option_length;
 		}
 


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/