summaryrefslogtreecommitdiffstats
path: root/testing/kdelibs/kdelibs-skipname.patch
blob: 7bcb5895eda9a5fe7e0978f8cf424152ae56e81f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--- kdelibs-4.6.3.orig/kio/misc/kpac/discovery.cpp
+++ kdelibs-4.6.3/kio/misc/kpac/discovery.cpp
@@ -90,6 +90,34 @@
         return !m_hostname.isEmpty();
     }
 
+    int
+    Discovery::skipName(const unsigned char *comp_dn, const unsigned char *eom) const
+    {
+	const u_char *cp;
+	int n;
+
+	cp = comp_dn;
+	while (cp < eom && (n = *cp++)) {
+		/*
+		 * check for indirection
+		 */
+		switch (n & INDIR_MASK) {
+		case 0:			/* normal case, n == len */
+			cp += n;
+			continue;
+		case INDIR_MASK:	/* indirection */
+			cp++;
+			break;
+		default:		/* illegal type */
+			return (-1);
+		}
+		break;
+	}
+	if (cp > eom)
+		return (-1);
+	return (cp - comp_dn);
+    }
+
     bool Discovery::checkDomain() const
     {
         // If a domain has a SOA record, don't traverse any higher.
@@ -107,10 +135,10 @@
         unsigned char* pos = response.buf + sizeof( response.header );
         unsigned char* end = response.buf + len;
         // skip query section
-        pos += dn_skipname( pos, end ) + QFIXEDSZ;
+        pos += this->skipName( pos, end ) + QFIXEDSZ;
         if ( pos >= end ) return true;
         // skip answer domain
-        pos += dn_skipname( pos, end );
+        pos += this->skipName( pos, end );
         short type;
         GETSHORT( type, pos );
         return type != T_SOA;
--- kdelibs-4.6.3.orig/kio/misc/kpac/discovery.h
+++ kdelibs-4.6.3/kio/misc/kpac/discovery.h
@@ -43,6 +43,7 @@
     private:
         bool initHostName();
         bool checkDomain() const;
+        int skipName(const unsigned char*, const unsigned char*) const;
 
         KProcess* m_helper;
         QString m_hostname;