Subversion Repositories

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

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

Rev Author Line No. Line
43 magnus 1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 02_fix_warnings.dpatch by Russell Coker <russell@coker.com.au>
3
##
4
## DP: Get rid of warnings through the use of const and more correct types
5
 
6
@DPATCH@
7
 
8
diff -ru libdkim-1.0.19.orig/src/dkim.cpp libdkim-1.0.19/src/dkim.cpp
9
--- libdkim-1.0.19.orig/src/dkim.cpp    2008-05-12 20:07:32.000000000 +1000
10
+++ libdkim-1.0.19/src/dkim.cpp 2009-04-15 19:38:08.000000000 +1000
11
@@ -172,7 +172,7 @@
12
 }
13
 
14
 
15
-int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, char* szBuffer, int nBufLength )
16
+int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, const char* const szBuffer, int nBufLength )
17
 {
18
        CDKIMVerify* pVerify = (CDKIMVerify*)ValidateContext( pVerifyContext, false );
19
 
20
@@ -226,13 +226,13 @@
21
 }
22
 
23
 
24
-char* DKIM_CALL DKIMVersion()
25
+const char* DKIM_CALL DKIMVersion()
26
 {
27
        return VERSION_STRING;
28
 }
29
 
30
 
31
-static char* DKIMErrorStrings[-1-DKIM_MAX_ERROR] = {
32
+static const char* DKIMErrorStrings[-1-DKIM_MAX_ERROR] = {
33
        "DKIM_FAIL",
34
        "DKIM_BAD_SYNTAX",
35
        "DKIM_SIGNATURE_BAD",
36
@@ -254,7 +254,7 @@
37
 };
38
 
39
 
40
-char* DKIM_CALL DKIMGetErrorString( int ErrorCode )
41
+const char* DKIM_CALL DKIMGetErrorString( int ErrorCode )
42
 {
43
        if (ErrorCode >= 0 || ErrorCode <= DKIM_MAX_ERROR)
44
                return "Unknown";
45
diff -ru libdkim-1.0.19.orig/src/dkim.h libdkim-1.0.19/src/dkim.h
46
--- libdkim-1.0.19.orig/src/dkim.h      2009-04-15 19:37:48.000000000 +1000
47
+++ libdkim-1.0.19/src/dkim.h   2009-04-15 19:38:08.000000000 +1000
48
@@ -155,14 +155,14 @@
49
 void DKIM_CALL DKIMSignFree( DKIMContext* pSignContext );
50
 
51
 int DKIM_CALL DKIMVerifyInit( DKIMContext* pVerifyContext, DKIMVerifyOptions* pOptions );
52
-int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, char* szBuffer, int nBufLength );
53
+int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, const char* szBuffer, int nBufLength );
54
 int DKIM_CALL DKIMVerifyResults( DKIMContext* pVerifyContext );
55
 int DKIM_CALL DKIMVerifyGetDetails( DKIMContext* pVerifyContext, int* nSigCount, DKIMVerifyDetails** pDetails, char* szPractices );
56
 void DKIM_CALL DKIMVerifyFree( DKIMContext* pVerifyContext );
57
 
58
-char *DKIM_CALL DKIMVersion();
59
+const char *DKIM_CALL DKIMVersion();
60
 
61
-char *DKIM_CALL DKIMGetErrorString( int ErrorCode );
62
+const char *DKIM_CALL DKIMGetErrorString( int ErrorCode );
63
 
64
 #ifdef __cplusplus
65
 }
66
diff -ru libdkim-1.0.19.orig/src/dkimbase.cpp libdkim-1.0.19/src/dkimbase.cpp
67
--- libdkim-1.0.19.orig/src/dkimbase.cpp        2008-05-12 20:07:36.000000000 +1000
68
+++ libdkim-1.0.19/src/dkimbase.cpp     2009-04-15 19:49:32.000000000 +1000
69
@@ -118,10 +118,10 @@
70
 // Process - split buffers into lines without any CRs or LFs at the end.
71
 //
72
 ////////////////////////////////////////////////////////////////////////////////
73
-int CDKIMBase::Process( char* szBuffer, int nBufLength, bool bEOF )
74
+int CDKIMBase::Process( const char* szBuffer, int nBufLength, bool bEOF )
75
 {
76
-       char* p = szBuffer;
77
-       char* e = szBuffer + nBufLength;
78
+       const char* p = szBuffer;
79
+       const char* e = szBuffer + nBufLength;
80
 
81
        while( p < e )
82
        {
83
@@ -208,7 +208,8 @@
84
        {
85
                m_InHeaders = false;
86
                ProcessHeaders();
87
-               ProcessBody("", 0, true);
88
+               /* type conversion should be safe as length is zero */
89
+               ProcessBody((char *)"", 0, true);
90
        }
91
 
92
        return DKIM_SUCCESS;
93
@@ -338,9 +339,9 @@
94
 
95
        CompressSWSP(sTemp);
96
 
97
-       unsigned cpos = sTemp.find(':');
98
+       string::size_type cpos = sTemp.find(':');
99
 
100
-       if (cpos == -1)
101
+       if (cpos == string::npos)
102
        {
103
                // no colon?!
104
        }
105
diff -ru libdkim-1.0.19.orig/src/dkimbase.h libdkim-1.0.19/src/dkimbase.h
106
--- libdkim-1.0.19.orig/src/dkimbase.h  2008-05-12 20:07:24.000000000 +1000
107
+++ libdkim-1.0.19/src/dkimbase.h       2009-04-15 19:49:32.000000000 +1000
108
@@ -41,7 +41,7 @@
109
 
110
        int Init(void);
111
 
112
-       int Process( char* szBuffer, int nBufLength, bool bEOF );
113
+       int Process( const char* szBuffer, int nBufLength, bool bEOF );
114
        int ProcessFinal(void);
115
 
116
        int Alloc( char*& szBuffer, int nRequiredSize );
117
diff -ru libdkim-1.0.19.orig/src/dkimsign.cpp libdkim-1.0.19/src/dkimsign.cpp
118
--- libdkim-1.0.19.orig/src/dkimsign.cpp        2008-05-12 20:07:46.000000000 +1000
119
+++ libdkim-1.0.19/src/dkimsign.cpp     2009-04-15 19:49:32.000000000 +1000
120
@@ -144,7 +144,7 @@
121
 
122
        fwrite( szBuffer, 1, nBufLength, fpdebug );
123
 
124
-       /** END DEBUG CODE **/
125
+       ** END DEBUG CODE **/
126
 
127
        if( bAllmanOnly )
128
        {
129
@@ -555,7 +555,7 @@
130
 //               if bFold, fold at cbrk char
131
 //
132
 ////////////////////////////////////////////////////////////////////////////////
133
-void CDKIMSign::AddTagToSig( char* Tag, const string &sValue, char cbrk, bool bFold )
134
+void CDKIMSign::AddTagToSig( const char* const Tag, const string &sValue, char cbrk, bool bFold )
135
 {
136
        int nTagLen = strlen(Tag);
137
 
138
@@ -583,10 +583,10 @@
139
 // AddTagToSig - add tag and numeric value to signature folding if necessary
140
 //
141
 ////////////////////////////////////////////////////////////////////////////////
142
-void CDKIMSign::AddTagToSig( char* Tag, unsigned long nValue )
143
+void CDKIMSign::AddTagToSig( const char* const Tag, unsigned long nValue )
144
 {
145
        char szValue[64];
146
-       sprintf( szValue, "%u", nValue );
147
+       sprintf( szValue, "%lu", nValue );
148
        AddTagToSig( Tag, szValue, 0, false );
149
 }
150
 
151
@@ -686,7 +686,7 @@
152
 // GetSig - compute hash and return signature header in szSignature
153
 //
154
 ////////////////////////////////////////////////////////////////////////////////
155
-int CDKIMSign::GetSig( char* szPrivKey, char* szSignature, int nSigLength )
156
+int CDKIMSign::GetSig( char* szPrivKey, char* szSignature, unsigned nSigLength )
157
 {
158
        if( szPrivKey == NULL )
159
        {
160
@@ -794,7 +794,6 @@
161
        int size;
162
        int len;
163
        char* buf;
164
-       int pos = 0;
165
 
166
        // construct the DKIM-Signature: header and add to hash
167
        InitSig();
168
@@ -879,7 +878,7 @@
169
                }
170
                BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
171
                BIO_push(b64, bio);
172
-               if (BIO_write(b64, Hash, nHashLen) < nHashLen) 
173
+               if (BIO_write(b64, Hash, nHashLen) < (int)nHashLen) 
174
                {
175
                  BIO_free_all(b64);
176
                  return DKIM_OUT_OF_MEMORY;
177
@@ -993,7 +992,7 @@
178
     }
179
     BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
180
     BIO_push(b64, bio);
181
-    if (BIO_write(b64, sig, siglen) < siglen) 
182
+    if (BIO_write(b64, sig, siglen) < (int)siglen) 
183
        {
184
       OPENSSL_free(sig);
185
       BIO_free_all(b64);
186
diff -ru libdkim-1.0.19.orig/src/dkimsign.h libdkim-1.0.19/src/dkimsign.h
187
--- libdkim-1.0.19.orig/src/dkimsign.h  2008-05-12 20:07:58.000000000 +1000
188
+++ libdkim-1.0.19/src/dkimsign.h       2009-04-15 19:49:32.000000000 +1000
189
@@ -32,7 +32,7 @@
190
 
191
        int Init( DKIMSignOptions* pOptions );
192
 
193
-       int GetSig( char* szPrivKey, char* szSignature, int nSigLength );
194
+       int GetSig( char* szPrivKey, char* szSignature, unsigned nSigLength );
195
        int GetSig2( char* szPrivKey, char** pszSignature );
196
 
197
        virtual int ProcessHeaders(void);
198
@@ -50,8 +50,8 @@
199
        bool ParseFromAddress( void );
200
 
201
        void InitSig(void);
202
-       void AddTagToSig( char* Tag, const string &sValue, char cbrk, bool bFold );
203
-       void AddTagToSig( char* Tag, unsigned long nValue );
204
+       void AddTagToSig( const char* const Tag, const string &sValue, char cbrk, bool bFold );
205
+       void AddTagToSig( const char* const Tag, unsigned long nValue );
206
        void AddInterTagSpace( int nSizeOfNextTag );
207
        void AddFoldedValueToSig( const string &sValue, char cbrk );
208
 
209
diff -ru libdkim-1.0.19.orig/src/dkimverify.cpp libdkim-1.0.19/src/dkimverify.cpp
210
--- libdkim-1.0.19.orig/src/dkimverify.cpp      2009-04-15 19:37:48.000000000 +1000
211
+++ libdkim-1.0.19/src/dkimverify.cpp   2009-04-15 19:49:32.000000000 +1000
212
@@ -440,7 +440,7 @@
213
 {
214
        ProcessFinal();
215
 
216
-       int SuccessCount=0;
217
+       unsigned int SuccessCount=0;
218
        int TestingFailures=0;
219
        int RealFailures=0;
220
 
221
@@ -646,7 +646,7 @@
222
        /** END DEBUG CODE **/
223
 #endif
224
 
225
-       if (IsBody && BodyLength != -1)
226
+       if (IsBody && BodyLength != (unsigned)-1)
227
        {
228
                VerifiedBodyCount += nBufLength;
229
                if (VerifiedBodyCount > BodyLength)
230
@@ -1019,7 +1019,7 @@
231
        // body count
232
        if (values[8] == NULL || !m_HonorBodyLengthTag)
233
        {
234
-               sig.BodyLength = -1;
235
+               sig.BodyLength = (unsigned)-1;
236
        }
237
        else
238
        {
239
@@ -1057,17 +1057,17 @@
240
        // expiration time
241
        if (values[11] == NULL)
242
        {
243
-               sig.ExpireTime = -1;
244
+               sig.ExpireTime = (unsigned)-1;
245
        }
246
        else
247
        {
248
                if (!ParseUnsigned(values[11], &sig.ExpireTime))
249
                        return DKIM_BAD_SYNTAX;
250
 
251
-               if (sig.ExpireTime != -1)
252
+               if (sig.ExpireTime != (unsigned)-1)
253
                {
254
                        // the value of x= MUST be greater than the value of t= if both are present
255
-                       if (SignedTime != -1 && sig.ExpireTime <= SignedTime)
256
+                       if (SignedTime != (unsigned)-1 && sig.ExpireTime <= SignedTime)
257
                                return DKIM_BAD_SYNTAX;
258
 
259
                        // todo: if possible, use the received date/time instead of the current time
260
@@ -1169,7 +1169,7 @@
261
 }
262
 
263
 
264
-SelectorInfo::SelectorInfo(const string &sSelector, const string &sDomain) : Selector(sSelector), Domain(sDomain)
265
+SelectorInfo::SelectorInfo(const string &sSelector, const string &sDomain) : Domain(sDomain), Selector(sSelector)
266
 {
267
        AllowSHA1 = true;
268
        AllowSHA256 = true;
269
@@ -1207,7 +1207,7 @@
270
                        return DKIM_SELECTOR_INVALID;           // todo: maybe create a new error code for unsupported selector version
271
 
272
                // make sure v= is the first tag in the response        // todo: maybe don't enforce this, it seems unnecessary
273
-               for (int j=1; j<sizeof(values)/sizeof(values[0]); j++)
274
+               for (unsigned j=1; j<sizeof(values)/sizeof(values[0]); j++)
275
                {
276
                        if (values[j] != NULL && values[j] < values[0])
277
                        {
278
diff -ru libdkim-1.0.19.orig/src/libdkimtest.cpp libdkim-1.0.19/src/libdkimtest.cpp
279
--- libdkim-1.0.19.orig/src/libdkimtest.cpp     2008-05-12 20:08:54.000000000 +1000
280
+++ libdkim-1.0.19/src/libdkimtest.cpp  2009-04-15 19:38:08.000000000 +1000
281
@@ -60,9 +60,9 @@
282
 int main(int argc, char* argv[])
283
 {
284
        int n;
285
-       char* PrivKeyFile = "test.pem";
286
-       char* MsgFile = "test.msg";
287
-       char* OutFile = "signed.msg";
288
+       const char* PrivKeyFile = "test.pem";
289
+       const char* MsgFile = "test.msg";
290
+       const char* OutFile = "signed.msg";
291
        int nPrivKeyLen;
292
        char PrivKey[2048];
293
        char Buffer[1024];