changeset 2253:9b39fde6d3e5 draft

Don't mistakenly assume that a previously used token implies we should encode the auth option.
author Roy Marples <roy@marples.name>
date Wed, 29 Jan 2014 19:46:44 +0000
parents 582257677e5d
children 1fd37d1ad6fb
files auth.c
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/auth.c	Wed Jan 29 18:33:43 2014 +0000
+++ b/auth.c	Wed Jan 29 19:46:44 2014 +0000
@@ -365,7 +365,7 @@
 	uint64_t rdm;
 	uint8_t hmac[HMAC_LENGTH];
 	time_t now;
-	uint8_t hops, *p;
+	uint8_t hops, *p, info;
 	uint32_t giaddr, secretid;
 
 	if (auth->protocol == 0 && t == NULL) {
@@ -415,6 +415,13 @@
 		return -1;
 	}
 
+	/* DISCOVER or INFORM messages don't write auth info */
+	if ((mp == 4 && (mt == DHCP_DISCOVER || mt == DHCP_INFORM)) ||
+	    (mp == 6 && (mt == DHCP6_SOLICIT || mt == DHCP6_INFORMATION_REQ)))
+		info = 0;
+	else
+		info = 1;
+
 	/* Work out the auth area size.
 	 * We only need to do this for DISCOVER messages */
 	if (data == NULL) {
@@ -424,11 +431,11 @@
 			dlen += t->key_len;
 			break;
 		case AUTH_PROTO_DELAYEDREALM:
-			if (t)
+			if (info && t)
 				dlen += t->realm_len;
 			/* FALLTHROUGH */
 		case AUTH_PROTO_DELAYED:
-			if (t)
+			if (info && t)
 				dlen += sizeof(t->secretid) + sizeof(hmac);
 			break;
 		}
@@ -480,8 +487,7 @@
 	}
 
 	/* DISCOVER or INFORM messages don't write auth info */
-	if ((mp == 4 && (mt == DHCP_DISCOVER || mt == DHCP_INFORM)) ||
-	    (mp == 6 && (mt == DHCP6_SOLICIT || mt == DHCP6_INFORMATION_REQ)))
+	if (!info)
 		return dlen;
 
 	/* Loading a saved lease without an authentication option */