Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Rev 40 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
40 magnus 1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 01_strtok_r.dpatch by Russell Coker <russell@coker.com.au>
3
##
4
## DP: Use strtok_r() instead of strtok().
5
 
6
@DPATCH@
7
 
8
diff -ru libdkim-1.0.19/src/dkimverify.cpp libdkim-1.0.19-new/src/dkimverify.cpp
9
--- libdkim-1.0.19/src/dkimverify.cpp	2008-05-12 20:08:06.000000000 +1000
10
+++ libdkim-1.0.19-new/src/dkimverify.cpp	2009-06-11 18:28:10.000000000 +1000
11
@@ -855,6 +855,9 @@
12
 ////////////////////////////////////////////////////////////////////////////////
13
 int CDKIMVerify::ParseDKIMSignature( const string& sHeader, SignatureInfo &sig )
14
 {
15
+	// for strtok_r()
16
+	char *saveptr;
17
+
18
 	// save header for later
19
 	sig.Header = sHeader;
20
 
21
@@ -1032,7 +1035,7 @@
22
 	{
23
 		// make sure "dns" is in the list
24
 		bool HasDNS = false;
25
-		char *s = strtok(values[9], ":");
26
+		char *s = strtok_r(values[9], ":", &saveptr);
27
 		while (s != NULL)
28
 		{
29
 			if (strncmp(s, "dns", 3) == 0 && (s[3] == '\0' || s[3] == '/'))
30
@@ -1040,7 +1043,7 @@
31
 				HasDNS = true;
32
 				break;
33
 			}
34
-			s = strtok(NULL, ": \t");
35
+			s = strtok_r(NULL, ": \t", &saveptr);
36
 		}
37
 		if (!HasDNS)
38
 			return DKIM_BAD_SYNTAX;		// todo: maybe create a new error code for unknown query method
39
@@ -1080,7 +1083,7 @@
40
 	// parse the signed headers list
41
 	bool HasFrom = false, HasSubject = false;
42
 	RemoveSWSP(values[4]);			// header names shouldn't have spaces in them so this should be ok...
43
-	char *s = strtok(values[4], ":");
44
+	char *s = strtok_r(values[4], ":", &saveptr);
45
 	while (s != NULL)
46
 	{
47
 		if (_stricmp(s, "From") == 0)
48
@@ -1090,7 +1093,7 @@
49
 
50
 		sig.SignedHeaders.push_back(s);
51
 
52
-		s = strtok(NULL, ":");
53
+		s = strtok_r(NULL, ":", &saveptr);
54
 	}
55
 
56
 	if (!HasFrom)
57
@@ -1194,6 +1197,9 @@
58
 ////////////////////////////////////////////////////////////////////////////////
59
 int SelectorInfo::Parse( char* Buffer )
60
 {
61
+	// for strtok_r()
62
+	char *saveptr;
63
+
64
 	static const char *tags[] = {"v","g","h","k","p","s","t","n",NULL};
65
 	char *values[sizeof(tags)/sizeof(tags[0])] = {NULL};
66
 
67
@@ -1235,14 +1241,14 @@
68
 	else
69
 	{
70
 		// MUST include "sha1" or "sha256"
71
-		char *s = strtok(values[2], ":");
72
+		char *s = strtok_r(values[2], ":", &saveptr);
73
 		while (s != NULL)
74
 		{
75
 			if (strcmp(s, "sha1") == 0)
76
 				AllowSHA1 = true;
77
 			else if (strcmp(s, "sha256") == 0)
78
 				AllowSHA256 = true;
79
-			s = strtok(NULL, ":");
80
+			s = strtok_r(NULL, ":", &saveptr);
81
 		}
82
 		if ( !(AllowSHA1 || AllowSHA256) )
83
 			return DKIM_SELECTOR_INVALID;	// todo: maybe create a new error code for unsupported hash algorithm
84
@@ -1261,7 +1267,7 @@
85
 	{
86
 		// make sure "*" or "email" is in the list
87
 		bool ServiceTypeMatch = false;
88
-		char *s = strtok(values[5], ":");
89
+		char *s = strtok_r(values[5], ":", &saveptr);
90
 		while (s != NULL)
91
 		{
92
 			if (strcmp(s, "*") == 0 || strcmp(s, "email") == 0)
93
@@ -1269,7 +1275,7 @@
94
 				ServiceTypeMatch = true;
95
 				break;
96
 			}
97
-			s = strtok(NULL, ":");
98
+			s = strtok_r(NULL, ":", &saveptr);
99
 		}
100
 		if (!ServiceTypeMatch)
101
 			return DKIM_SELECTOR_INVALID;
102
@@ -1278,7 +1284,7 @@
103
 	// flags
104
 	if (values[6] != NULL)
105
 	{
106
-		char *s = strtok(values[6], ":");
107
+		char *s = strtok_r(values[6], ":", &saveptr);
108
 		while (s != NULL)
109
 		{
110
 			if (strcmp(s, "y") == 0)
111
@@ -1289,7 +1295,7 @@
112
 			{
113
 				SameDomain = true;
114
 			}
115
-			s = strtok(NULL, ":");
116
+			s = strtok_r(NULL, ":", &saveptr);
117
 		}
118
 	}
119