Index: query.c
===================================================================
RCS file: /cvs/nsd/query.c,v
retrieving revision 1.83
diff -u -r1.83 query.c
--- query.c	14 Oct 2002 13:12:16 -0000	1.83
+++ query.c	17 Jul 2003 09:17:33 -0000
@@ -397,9 +397,10 @@
 	qname = qptr = q->iobuf + QHEADERSZ;
 	while(*qptr) {
 		/*  If we are out of buffer limits or we have a pointer in question dname or the domain name is longer than MAXDOMAINLEN ... */
-		if((qptr + *qptr > q->iobufptr) || (*qptr & 0xc0) ||
-			((qptr - q->iobuf + *qptr) > MAXDOMAINLEN)) {
-
+		if ((*qptr & 0xc0) ||
+		    (qptr + *qptr + 1 > q->iobufptr) || 
+		    (qptr + *qptr + 1 > q->iobuf + QHEADERSZ + MAXDOMAINLEN))
+		{
 			query_formerr(q);
 			return 0;
 		}

