Index: query.c
===================================================================
RCS file: /cvs/nsd/query.c,v
retrieving revision 1.125
diff -u -r1.125 query.c
--- query.c	7 Jul 2003 12:59:37 -0000	1.125
+++ query.c	17 Jul 2003 08:46:26 -0000
@@ -356,8 +356,10 @@
 		 * in question dname or the domain name is longer than
 		 * MAXDOMAINLEN ...
 		 */
-		if ((*src & 0xc0) || (src + *src > query->iobufptr) || 
-		    ((src - query->iobuf + *src) > MAXDOMAINLEN)) {
+		if ((*src & 0xc0) ||
+		    (src + *src + 1 > query->iobufptr) || 
+		    (src + *src + 1 > query_name + MAXDOMAINLEN))
+		{
 			query_formerr(query);
 			return NULL;
 		}
