From dan@xkulesh.vol.cz  Thu Sep 27 00:51:27 2001
Return-Path: <dan@xkulesh.vol.cz>
Received: from xkulesh.vol.cz (xkulesh.vol.cz [195.250.154.106])
	by hub.freebsd.org (Postfix) with ESMTP id 48F0037B406
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 27 Sep 2001 00:51:24 -0700 (PDT)
Received: (from root@localhost)
	by xkulesh.vol.cz (8.11.4/8.11.4) id f8R1gEH43139;
	Thu, 27 Sep 2001 03:42:14 +0200 (CEST)
	(envelope-from dan)
Message-Id: <200109270142.f8R1gEH43139@xkulesh.vol.cz>
Date: Thu, 27 Sep 2001 03:42:14 +0200 (CEST)
From: Dan Lukes <dan@obluda.cz>
Reply-To: Dan Lukes <dan@obluda.cz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: bootpd/dovend.c Win95 compatibility improvement and typos in error messages
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         30863
>Category:       bin
>Synopsis:       bootpd(8) dovend.c Win95 compatibility improvement and typos in error messages
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 27 01:00:01 PDT 2001
>Closed-Date:    
>Last-Modified:  Wed May 21 21:13:17 UTC 2008
>Originator:     Dan Lukes
>Release:        FreeBSD 4.4-STABLE i386
>Organization:
Obludarium
>Environment:
System: FreeBSD 4.4-STABLE #31: Thu Sep 20 23:06:53 CEST 2001 i386

>Description:
	There are several copy&paste typos in NEED macro causing incorrect
error messages.

	Win95 release ignore dn (domain-name) field unless <NUL> terminated.
Padding shouldn't cause a problem on other systems

>How-To-Repeat:
>Fix:
--- libexec/bootpd/dovend.c.orig	Sat Aug 28 02:09:17 1999
+++ libexec/bootpd/dovend.c	Thu Sep 27 03:34:41 2001
@@ -137,14 +138,17 @@
 		/*
 		 * Check for room for domain_name.  Add 2 to account for
 		 * TAG_DOMAIN_NAME and length.
+		 * Add one more for a 'PAD' option to make
+		 * the string zero-terminated for Win95 to work.
 		 */
 		len = strlen(hp->domain_name->string);
-		NEED((len + 2), "dn");
+		NEED((len + 3), "dn");
 		*vp++ = TAG_DOMAIN_NAME;
 		*vp++ = (byte) (len & 0xFF);
 		bcopy(hp->domain_name->string, vp, len);
 		vp += len;
-		bytesleft -= len + 2;
+		bytesleft -= len + 3;
+		*vp++ = '\0';		/* Courtesy to M$ */
 	}
 	/*
 	 * NIS (YP) server and domain
@@ -153,7 +157,7 @@
 		if (insert_ip(TAG_NIS_SERVER,
 					  hp->nis_server,
 					  &vp, &bytesleft))
-			NEED(8, "ds");
+			NEED(8, "ys");
 	}
 	if (hp->flags.nis_domain) {
 		/*
@@ -161,7 +165,7 @@
 		 * TAG_NIS_DOMAIN and length.
 		 */
 		len = strlen(hp->nis_domain->string);
-		NEED((len + 2), "dn");
+		NEED((len + 2), "yn");
 		*vp++ = TAG_NIS_DOMAIN;
 		*vp++ = (byte) (len & 0xFF);
 		bcopy(hp->nis_domain->string, vp, len);
@@ -193,7 +197,7 @@
 		if (insert_ip(TAG_NTP_SERVER,
 					  hp->ntp_server,
 					  &vp, &bytesleft))
-			NEED(8, "ts");
+			NEED(8, "nt");
 	}
 	/*
 	 * I wonder:  If the hostname were "promoted" into the BOOTP
>Release-Note:
>Audit-Trail:

From: Ian Dowse <iedowse@maths.tcd.ie>
To: Dan Lukes <dan@obluda.cz>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/30863: bootpd/dovend.c Win95 compatibility improvement and typos in error messages 
Date: Sat, 29 Sep 2001 12:59:19 +0100

 In message <200109270142.f8R1gEH43139@xkulesh.vol.cz>, Dan Lukes writes:
 >
 >	Win95 release ignore dn (domain-name) field unless <NUL> terminated.
 >Padding shouldn't cause a problem on other systems
 
 Hi,
 
 The ISC dhcpd only NUL-terminates replies when it detects a Microsoft
 client that requires it:
 
         /* Set a flag if this client is a lame Microsoft client that NUL
            terminates string options and expects us to do likewise. */
         if (packet -> options [DHO_HOST_NAME].data &&
             packet -> options [DHO_HOST_NAME].data
             [packet -> options [DHO_HOST_NAME].len - 1] == '\0')
                 lease -> flags |= MS_NULL_TERMINATION;
         else
                 lease -> flags &= ~MS_NULL_TERMINATION;
 
 How easy would it be to do something like this in our bootpd instead?
 ISC-dhcpd is much more actively developed and widely used than bootpd
 is, so it's probably better to try and follow dhcpd's approach where
 possible to avoid problems that they may have already solved.
 
 Ian
>Unformatted:
