summaryrefslogtreecommitdiff
path: root/mail-filter/libdkim/files/patches/fix_warnings.patch
blob: 84704290a60a9b8b9937facdf387cd9cbc62fb30 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#! /bin/sh /usr/share/dpatch/dpatch-run
## 02_fix_warnings.dpatch by Russell Coker <russell@coker.com.au>
##
## DP: Get rid of warnings through the use of const and more correct types

@DPATCH@

diff -ru src/dkim.cpp src/dkim.cpp
--- src/dkim.cpp	2008-05-12 20:07:32.000000000 +1000
+++ src/dkim.cpp	2009-04-15 19:38:08.000000000 +1000
@@ -172,7 +172,7 @@
 }
 
 
-int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, char* szBuffer, int nBufLength )
+int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, const char* const szBuffer, int nBufLength )
 {
 	CDKIMVerify* pVerify = (CDKIMVerify*)ValidateContext( pVerifyContext, false );
 
@@ -226,13 +226,13 @@
 }
 
 
-char* DKIM_CALL DKIMVersion()
+const char* DKIM_CALL DKIMVersion()
 {
 	return VERSION_STRING;
 }
 
 
-static char* DKIMErrorStrings[-1-DKIM_MAX_ERROR] = {
+static const char* DKIMErrorStrings[-1-DKIM_MAX_ERROR] = {
 	"DKIM_FAIL",
 	"DKIM_BAD_SYNTAX",
 	"DKIM_SIGNATURE_BAD",
@@ -254,7 +254,7 @@
 };
 
 
-char* DKIM_CALL DKIMGetErrorString( int ErrorCode )
+const char* DKIM_CALL DKIMGetErrorString( int ErrorCode )
 {
 	if (ErrorCode >= 0 || ErrorCode <= DKIM_MAX_ERROR)
 		return "Unknown";
diff -ru src/dkim.h src/dkim.h
--- src/dkim.h	2009-04-15 19:37:48.000000000 +1000
+++ src/dkim.h	2009-04-15 19:38:08.000000000 +1000
@@ -155,14 +155,14 @@
 void DKIM_CALL DKIMSignFree( DKIMContext* pSignContext );
 
 int DKIM_CALL DKIMVerifyInit( DKIMContext* pVerifyContext, DKIMVerifyOptions* pOptions );
-int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, char* szBuffer, int nBufLength );
+int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, const char* szBuffer, int nBufLength );
 int DKIM_CALL DKIMVerifyResults( DKIMContext* pVerifyContext );
 int DKIM_CALL DKIMVerifyGetDetails( DKIMContext* pVerifyContext, int* nSigCount, DKIMVerifyDetails** pDetails, char* szPractices );
 void DKIM_CALL DKIMVerifyFree( DKIMContext* pVerifyContext );
 
-char *DKIM_CALL DKIMVersion();
+const char *DKIM_CALL DKIMVersion();
 
-char *DKIM_CALL DKIMGetErrorString( int ErrorCode );
+const char *DKIM_CALL DKIMGetErrorString( int ErrorCode );
 
 #ifdef __cplusplus
 }
diff -ru src/dkimbase.cpp src/dkimbase.cpp
--- src/dkimbase.cpp	2008-05-12 20:07:36.000000000 +1000
+++ src/dkimbase.cpp	2009-04-15 19:49:32.000000000 +1000
@@ -118,10 +118,10 @@
 // Process - split buffers into lines without any CRs or LFs at the end.
 //
 ////////////////////////////////////////////////////////////////////////////////
-int CDKIMBase::Process( char* szBuffer, int nBufLength, bool bEOF )
+int CDKIMBase::Process( const char* szBuffer, int nBufLength, bool bEOF )
 {
-	char* p = szBuffer;
-	char* e = szBuffer + nBufLength;
+	const char* p = szBuffer;
+	const char* e = szBuffer + nBufLength;
 
 	while( p < e )
 	{
@@ -208,7 +208,8 @@
 	{
 		m_InHeaders = false;
 		ProcessHeaders();
-		ProcessBody("", 0, true);
+		/* type conversion should be safe as length is zero */
+		ProcessBody((char *)"", 0, true);
 	}
 
 	return DKIM_SUCCESS;
@@ -338,9 +339,9 @@
 
 	CompressSWSP(sTemp);
 
-	unsigned cpos = sTemp.find(':');
+	string::size_type cpos = sTemp.find(':');
 
-	if (cpos == -1)
+	if (cpos == string::npos)
 	{
 		// no colon?!
 	}
diff -ru src/dkimbase.h src/dkimbase.h
--- src/dkimbase.h	2008-05-12 20:07:24.000000000 +1000
+++ src/dkimbase.h	2009-04-15 19:49:32.000000000 +1000
@@ -41,7 +41,7 @@
 
 	int Init(void);
 
-	int Process( char* szBuffer, int nBufLength, bool bEOF );
+	int Process( const char* szBuffer, int nBufLength, bool bEOF );
 	int ProcessFinal(void);
 
 	int Alloc( char*& szBuffer, int nRequiredSize );
diff -ru src/dkimsign.cpp src/dkimsign.cpp
--- src/dkimsign.cpp	2008-05-12 20:07:46.000000000 +1000
+++ src/dkimsign.cpp	2009-04-15 19:49:32.000000000 +1000
@@ -144,7 +144,7 @@
 
 	fwrite( szBuffer, 1, nBufLength, fpdebug );
 
-	/** END DEBUG CODE **/
+	** END DEBUG CODE **/
 
 	if( bAllmanOnly )
 	{
@@ -555,7 +555,7 @@
 //               if bFold, fold at cbrk char
 //
 ////////////////////////////////////////////////////////////////////////////////
-void CDKIMSign::AddTagToSig( char* Tag, const string &sValue, char cbrk, bool bFold )
+void CDKIMSign::AddTagToSig( const char* const Tag, const string &sValue, char cbrk, bool bFold )
 {
 	int nTagLen = strlen(Tag);
 
@@ -583,10 +583,10 @@
 // AddTagToSig - add tag and numeric value to signature folding if necessary
 //
 ////////////////////////////////////////////////////////////////////////////////
-void CDKIMSign::AddTagToSig( char* Tag, unsigned long nValue )
+void CDKIMSign::AddTagToSig( const char* const Tag, unsigned long nValue )
 {
 	char szValue[64];
-	sprintf( szValue, "%u", nValue );
+	sprintf( szValue, "%lu", nValue );
 	AddTagToSig( Tag, szValue, 0, false );
 }
 
@@ -686,7 +686,7 @@
 // GetSig - compute hash and return signature header in szSignature
 //
 ////////////////////////////////////////////////////////////////////////////////
-int CDKIMSign::GetSig( char* szPrivKey, char* szSignature, int nSigLength )
+int CDKIMSign::GetSig( char* szPrivKey, char* szSignature, unsigned nSigLength )
 {
 	if( szPrivKey == NULL )
 	{
@@ -794,7 +794,6 @@
 	int size;
 	int len;
 	char* buf;
-	int pos = 0;
 	
 	// construct the DKIM-Signature: header and add to hash
 	InitSig();
@@ -879,7 +878,7 @@
 		}
 		BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
 		BIO_push(b64, bio);
-		if (BIO_write(b64, Hash, nHashLen) < nHashLen) 
+		if (BIO_write(b64, Hash, nHashLen) < (int)nHashLen) 
 		{
 		  BIO_free_all(b64);
 		  return DKIM_OUT_OF_MEMORY;
@@ -993,7 +992,7 @@
     }
     BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
     BIO_push(b64, bio);
-    if (BIO_write(b64, sig, siglen) < siglen) 
+    if (BIO_write(b64, sig, siglen) < (int)siglen) 
 	{
       OPENSSL_free(sig);
       BIO_free_all(b64);
diff -ru src/dkimsign.h src/dkimsign.h
--- src/dkimsign.h	2008-05-12 20:07:58.000000000 +1000
+++ src/dkimsign.h	2009-04-15 19:49:32.000000000 +1000
@@ -32,7 +32,7 @@
 
 	int Init( DKIMSignOptions* pOptions );
 
-	int GetSig( char* szPrivKey, char* szSignature, int nSigLength );
+	int GetSig( char* szPrivKey, char* szSignature, unsigned nSigLength );
 	int GetSig2( char* szPrivKey, char** pszSignature );
 
 	virtual int ProcessHeaders(void);
@@ -50,8 +50,8 @@
 	bool ParseFromAddress( void );
 
 	void InitSig(void);
-	void AddTagToSig( char* Tag, const string &sValue, char cbrk, bool bFold );
-	void AddTagToSig( char* Tag, unsigned long nValue );
+	void AddTagToSig( const char* const Tag, const string &sValue, char cbrk, bool bFold );
+	void AddTagToSig( const char* const Tag, unsigned long nValue );
 	void AddInterTagSpace( int nSizeOfNextTag );
 	void AddFoldedValueToSig( const string &sValue, char cbrk );
 
diff -ru src/dkimverify.cpp src/dkimverify.cpp
--- src/dkimverify.cpp	2009-04-15 19:37:48.000000000 +1000
+++ src/dkimverify.cpp	2009-04-15 19:49:32.000000000 +1000
@@ -440,7 +440,7 @@
 {
 	ProcessFinal();
 
-	int SuccessCount=0;
+	unsigned int SuccessCount=0;
 	int TestingFailures=0;
 	int RealFailures=0;
 
@@ -646,7 +646,7 @@
 	/** END DEBUG CODE **/
 #endif
 
-	if (IsBody && BodyLength != -1)
+	if (IsBody && BodyLength != (unsigned)-1)
 	{
 		VerifiedBodyCount += nBufLength;
 		if (VerifiedBodyCount > BodyLength)
@@ -1019,7 +1019,7 @@
 	// body count
 	if (values[8] == NULL || !m_HonorBodyLengthTag)
 	{
-		sig.BodyLength = -1;
+		sig.BodyLength = (unsigned)-1;
 	}
 	else
 	{
@@ -1057,17 +1057,17 @@
 	// expiration time
 	if (values[11] == NULL)
 	{
-		sig.ExpireTime = -1;
+		sig.ExpireTime = (unsigned)-1;
 	}
 	else
 	{
 		if (!ParseUnsigned(values[11], &sig.ExpireTime))
 			return DKIM_BAD_SYNTAX;
 
-		if (sig.ExpireTime != -1)
+		if (sig.ExpireTime != (unsigned)-1)
 		{
 			// the value of x= MUST be greater than the value of t= if both are present
-			if (SignedTime != -1 && sig.ExpireTime <= SignedTime)
+			if (SignedTime != (unsigned)-1 && sig.ExpireTime <= SignedTime)
 				return DKIM_BAD_SYNTAX;
 
 			// todo: if possible, use the received date/time instead of the current time
@@ -1169,7 +1169,7 @@
 }
 
 
-SelectorInfo::SelectorInfo(const string &sSelector, const string &sDomain) : Selector(sSelector), Domain(sDomain)
+SelectorInfo::SelectorInfo(const string &sSelector, const string &sDomain) : Domain(sDomain), Selector(sSelector)
 {
 	AllowSHA1 = true;
 	AllowSHA256 = true;
@@ -1207,7 +1207,7 @@
 			return DKIM_SELECTOR_INVALID;		// todo: maybe create a new error code for unsupported selector version
 
 		// make sure v= is the first tag in the response	// todo: maybe don't enforce this, it seems unnecessary
-		for (int j=1; j<sizeof(values)/sizeof(values[0]); j++)
+		for (unsigned j=1; j<sizeof(values)/sizeof(values[0]); j++)
 		{
 			if (values[j] != NULL && values[j] < values[0])
 			{
diff -ru src/libdkimtest.cpp src/libdkimtest.cpp
--- src/libdkimtest.cpp	2008-05-12 20:08:54.000000000 +1000
+++ src/libdkimtest.cpp	2009-04-15 19:38:08.000000000 +1000
@@ -60,9 +60,9 @@
 int main(int argc, char* argv[])
 {
 	int n;
-	char* PrivKeyFile = "test.pem";
-	char* MsgFile = "test.msg";
-	char* OutFile = "signed.msg";
+	const char* PrivKeyFile = "test.pem";
+	const char* MsgFile = "test.msg";
+	const char* OutFile = "signed.msg";
 	int nPrivKeyLen;
 	char PrivKey[2048];
 	char Buffer[1024];