Re: smtpd w/ async DNS

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Faurot
Date: Saturday, October 30, 2010 - 12:26 pm

On Sat, Oct 30, 2010 at 07:26:00PM +0200, Peter J. Philipp wrote:


You are totally right. The following patch should fix it. Thanks a lot.

Eric.

--- pack.c.orig	Sat Oct 30 21:22:14 2010
+++ pack.c	Sat Oct 30 21:22:06 2010
@@ -38,21 +38,21 @@ ssize_t
 dname_expand(const unsigned char *data, size_t len, size_t offset,
     size_t *newoffset, char *dst, size_t max)
 {
-	size_t		 n, count, end, ptr;
+	size_t		 n, count, end, ptr, start;
 	ssize_t		 res;
 
 	if (offset >= len)
 		return (-1);
 
 	res = 0;
-	end = offset;
+	end = start = offset;
 
 	for(; (n = data[offset]); ) {
 		if ((n & 0xc0) == 0xc0) {
 			if (offset + 2 > len)
 				return (-1);
 			ptr = 256 * (n & ~0xc0) + data[offset + 1];
-			if (ptr >= offset)
+			if (ptr >= start)
 				return (-1);
 			if (end < offset + 2)
 				end = offset + 2;
@@ -91,8 +91,9 @@ const char *
 dname_nthlabel(int n, const unsigned char *data, size_t len, size_t offset)
 {
 	int		 i;
-	size_t		 c, ptr;
+	size_t		 c, ptr, start;
 
+	start = offset;
 	for(i = 0;;) {
 		c = data[offset];
 		if (c == 0)
@@ -101,7 +102,7 @@ dname_nthlabel(int n, const unsigned char *data, size_
 			if (len < offset + 2)
 				return (NULL);
 			ptr = 256 * (c & ~0xc0) + data[offset + 1];
-			if (ptr >= offset)
+			if (ptr >= start)
 				return (NULL);
 			offset = ptr;
 			continue;
@@ -117,14 +118,15 @@ dname_nthlabel(int n, const unsigned char *data, size_
 ssize_t
 dname_count_labels(const unsigned char *data, size_t len, size_t offset)
 {
-	size_t c, n, ptr;
+	size_t c, n, ptr, start;
 
+	start = offset;
 	for(n = 0; (c = data[offset]); ) {
 		if ((c & 0xc0) == 0xc0) {
 			if (len < offset + 2)
 				return (-1);
 			ptr = 256 * (c & ~0xc0) + data[offset + 1];
-			if (ptr >= offset)
+			if (ptr >= start)
 				return (-1);
 			offset = ptr;
 			continue;
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
smtpd w/ async DNS, Gilles Chehade, (Thu Oct 14, 7:47 am)
Re: smtpd w/ async DNS, Ted Unangst, (Thu Oct 14, 8:06 am)
Re: smtpd w/ async DNS, Mike Belopuhov, (Thu Oct 14, 8:10 am)
Re: smtpd w/ async DNS, Gilles Chehade, (Thu Oct 14, 8:17 am)
Re: smtpd w/ async DNS, Ted Unangst, (Thu Oct 14, 8:30 am)
Re: smtpd w/ async DNS, Christiano F. Haesbaert, (Thu Oct 14, 8:37 am)
Re: smtpd w/ async DNS, Gilles Chehade, (Thu Oct 14, 8:39 am)
Re: smtpd w/ async DNS, Christian Weisgerber, (Thu Oct 14, 8:59 am)
Re: smtpd w/ async DNS, Peter J. Philipp, (Thu Oct 14, 9:50 am)
Re: smtpd w/ async DNS, Mike Belopuhov, (Thu Oct 14, 11:57 am)
Re: smtpd w/ async DNS, Matthew Dempsky, (Thu Oct 14, 2:08 pm)
Re: smtpd w/ async DNS, Gilles Chehade, (Fri Oct 15, 1:50 am)
Re: smtpd w/ async DNS, Damien Miller, (Fri Oct 15, 2:38 am)
Re: smtpd w/ async DNS, Gilles Chehade, (Sat Oct 30, 7:55 am)
Re: smtpd w/ async DNS, Peter J. Philipp, (Sat Oct 30, 8:23 am)
Re: smtpd w/ async DNS, Gilles Chehade, (Sat Oct 30, 8:28 am)
Re: smtpd w/ async DNS, Peter J. Philipp, (Sat Oct 30, 10:26 am)
Re: smtpd w/ async DNS, Eric Faurot, (Sat Oct 30, 12:26 pm)