Gentoo Archives: gentoo-commits

From: "Alexander Vershilov (qnikst)" <qnikst@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in mail-filter/libdkim/files/patches: strtok_r.patch fix_warnings.patch series
Date: Sat, 01 Sep 2012 09:12:28
Message-Id: 20120901091201.BF22720E82@flycatcher.gentoo.org
1 qnikst 12/09/01 09:12:01
2
3 Added: strtok_r.patch fix_warnings.patch series
4 Log:
5 adding libdkim ebuild, thanks to slepnoga #262919
6
7 (Portage version: 2.2.0_alpha120/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 mail-filter/libdkim/files/patches/strtok_r.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/mail-filter/libdkim/files/patches/strtok_r.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/mail-filter/libdkim/files/patches/strtok_r.patch?rev=1.1&content-type=text/plain
14
15 Index: strtok_r.patch
16 ===================================================================
17 #! /bin/sh /usr/share/dpatch/dpatch-run
18 ## 01_strtok_r.dpatch by Russell Coker <russell@×××××××××.au>
19 ##
20 ## DP: Use strtok_r() instead of strtok().
21
22 @DPATCH@
23
24 diff -ru libdkim-1.0.19/src/dkimverify.cpp libdkim-1.0.19-new/src/dkimverify.cpp
25 --- libdkim-1.0.19/src/dkimverify.cpp 2008-05-12 20:08:06.000000000 +1000
26 +++ libdkim-1.0.19-new/src/dkimverify.cpp 2009-06-11 18:28:10.000000000 +1000
27 @@ -855,6 +855,9 @@
28 ////////////////////////////////////////////////////////////////////////////////
29 int CDKIMVerify::ParseDKIMSignature( const string& sHeader, SignatureInfo &sig )
30 {
31 + // for strtok_r()
32 + char *saveptr;
33 +
34 // save header for later
35 sig.Header = sHeader;
36
37 @@ -1032,7 +1035,7 @@
38 {
39 // make sure "dns" is in the list
40 bool HasDNS = false;
41 - char *s = strtok(values[9], ":");
42 + char *s = strtok_r(values[9], ":", &saveptr);
43 while (s != NULL)
44 {
45 if (strncmp(s, "dns", 3) == 0 && (s[3] == '\0' || s[3] == '/'))
46 @@ -1040,7 +1043,7 @@
47 HasDNS = true;
48 break;
49 }
50 - s = strtok(NULL, ": \t");
51 + s = strtok_r(NULL, ": \t", &saveptr);
52 }
53 if (!HasDNS)
54 return DKIM_BAD_SYNTAX; // todo: maybe create a new error code for unknown query method
55 @@ -1080,7 +1083,7 @@
56 // parse the signed headers list
57 bool HasFrom = false, HasSubject = false;
58 RemoveSWSP(values[4]); // header names shouldn't have spaces in them so this should be ok...
59 - char *s = strtok(values[4], ":");
60 + char *s = strtok_r(values[4], ":", &saveptr);
61 while (s != NULL)
62 {
63 if (_stricmp(s, "From") == 0)
64 @@ -1090,7 +1093,7 @@
65
66 sig.SignedHeaders.push_back(s);
67
68 - s = strtok(NULL, ":");
69 + s = strtok_r(NULL, ":", &saveptr);
70 }
71
72 if (!HasFrom)
73 @@ -1194,6 +1197,9 @@
74 ////////////////////////////////////////////////////////////////////////////////
75 int SelectorInfo::Parse( char* Buffer )
76 {
77 + // for strtok_r()
78 + char *saveptr;
79 +
80 static const char *tags[] = {"v","g","h","k","p","s","t","n",NULL};
81 char *values[sizeof(tags)/sizeof(tags[0])] = {NULL};
82
83 @@ -1235,14 +1241,14 @@
84 else
85 {
86 // MUST include "sha1" or "sha256"
87 - char *s = strtok(values[2], ":");
88 + char *s = strtok_r(values[2], ":", &saveptr);
89 while (s != NULL)
90 {
91 if (strcmp(s, "sha1") == 0)
92 AllowSHA1 = true;
93 else if (strcmp(s, "sha256") == 0)
94 AllowSHA256 = true;
95 - s = strtok(NULL, ":");
96 + s = strtok_r(NULL, ":", &saveptr);
97 }
98 if ( !(AllowSHA1 || AllowSHA256) )
99 return DKIM_SELECTOR_INVALID; // todo: maybe create a new error code for unsupported hash algorithm
100 @@ -1261,7 +1267,7 @@
101 {
102 // make sure "*" or "email" is in the list
103 bool ServiceTypeMatch = false;
104 - char *s = strtok(values[5], ":");
105 + char *s = strtok_r(values[5], ":", &saveptr);
106 while (s != NULL)
107 {
108 if (strcmp(s, "*") == 0 || strcmp(s, "email") == 0)
109 @@ -1269,7 +1275,7 @@
110 ServiceTypeMatch = true;
111 break;
112 }
113 - s = strtok(NULL, ":");
114 + s = strtok_r(NULL, ":", &saveptr);
115 }
116 if (!ServiceTypeMatch)
117 return DKIM_SELECTOR_INVALID;
118 @@ -1278,7 +1284,7 @@
119 // flags
120 if (values[6] != NULL)
121 {
122 - char *s = strtok(values[6], ":");
123 + char *s = strtok_r(values[6], ":", &saveptr);
124 while (s != NULL)
125 {
126 if (strcmp(s, "y") == 0)
127 @@ -1289,7 +1295,7 @@
128 {
129 SameDomain = true;
130 }
131 - s = strtok(NULL, ":");
132 + s = strtok_r(NULL, ":", &saveptr);
133 }
134 }
135
136
137
138
139 1.1 mail-filter/libdkim/files/patches/fix_warnings.patch
140
141 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/mail-filter/libdkim/files/patches/fix_warnings.patch?rev=1.1&view=markup
142 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/mail-filter/libdkim/files/patches/fix_warnings.patch?rev=1.1&content-type=text/plain
143
144 Index: fix_warnings.patch
145 ===================================================================
146 #! /bin/sh /usr/share/dpatch/dpatch-run
147 ## 02_fix_warnings.dpatch by Russell Coker <russell@×××××××××.au>
148 ##
149 ## DP: Get rid of warnings through the use of const and more correct types
150
151 @DPATCH@
152
153 diff -ru libdkim-1.0.19.orig/src/dkim.cpp libdkim-1.0.19/src/dkim.cpp
154 --- libdkim-1.0.19.orig/src/dkim.cpp 2008-05-12 20:07:32.000000000 +1000
155 +++ libdkim-1.0.19/src/dkim.cpp 2009-04-15 19:38:08.000000000 +1000
156 @@ -172,7 +172,7 @@
157 }
158
159
160 -int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, char* szBuffer, int nBufLength )
161 +int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, const char* const szBuffer, int nBufLength )
162 {
163 CDKIMVerify* pVerify = (CDKIMVerify*)ValidateContext( pVerifyContext, false );
164
165 @@ -226,13 +226,13 @@
166 }
167
168
169 -char* DKIM_CALL DKIMVersion()
170 +const char* DKIM_CALL DKIMVersion()
171 {
172 return VERSION_STRING;
173 }
174
175
176 -static char* DKIMErrorStrings[-1-DKIM_MAX_ERROR] = {
177 +static const char* DKIMErrorStrings[-1-DKIM_MAX_ERROR] = {
178 "DKIM_FAIL",
179 "DKIM_BAD_SYNTAX",
180 "DKIM_SIGNATURE_BAD",
181 @@ -254,7 +254,7 @@
182 };
183
184
185 -char* DKIM_CALL DKIMGetErrorString( int ErrorCode )
186 +const char* DKIM_CALL DKIMGetErrorString( int ErrorCode )
187 {
188 if (ErrorCode >= 0 || ErrorCode <= DKIM_MAX_ERROR)
189 return "Unknown";
190 diff -ru libdkim-1.0.19.orig/src/dkim.h libdkim-1.0.19/src/dkim.h
191 --- libdkim-1.0.19.orig/src/dkim.h 2009-04-15 19:37:48.000000000 +1000
192 +++ libdkim-1.0.19/src/dkim.h 2009-04-15 19:38:08.000000000 +1000
193 @@ -155,14 +155,14 @@
194 void DKIM_CALL DKIMSignFree( DKIMContext* pSignContext );
195
196 int DKIM_CALL DKIMVerifyInit( DKIMContext* pVerifyContext, DKIMVerifyOptions* pOptions );
197 -int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, char* szBuffer, int nBufLength );
198 +int DKIM_CALL DKIMVerifyProcess( DKIMContext* pVerifyContext, const char* szBuffer, int nBufLength );
199 int DKIM_CALL DKIMVerifyResults( DKIMContext* pVerifyContext );
200 int DKIM_CALL DKIMVerifyGetDetails( DKIMContext* pVerifyContext, int* nSigCount, DKIMVerifyDetails** pDetails, char* szPractices );
201 void DKIM_CALL DKIMVerifyFree( DKIMContext* pVerifyContext );
202
203 -char *DKIM_CALL DKIMVersion();
204 +const char *DKIM_CALL DKIMVersion();
205
206 -char *DKIM_CALL DKIMGetErrorString( int ErrorCode );
207 +const char *DKIM_CALL DKIMGetErrorString( int ErrorCode );
208
209 #ifdef __cplusplus
210 }
211 diff -ru libdkim-1.0.19.orig/src/dkimbase.cpp libdkim-1.0.19/src/dkimbase.cpp
212 --- libdkim-1.0.19.orig/src/dkimbase.cpp 2008-05-12 20:07:36.000000000 +1000
213 +++ libdkim-1.0.19/src/dkimbase.cpp 2009-04-15 19:49:32.000000000 +1000
214 @@ -118,10 +118,10 @@
215 // Process - split buffers into lines without any CRs or LFs at the end.
216 //
217 ////////////////////////////////////////////////////////////////////////////////
218 -int CDKIMBase::Process( char* szBuffer, int nBufLength, bool bEOF )
219 +int CDKIMBase::Process( const char* szBuffer, int nBufLength, bool bEOF )
220 {
221 - char* p = szBuffer;
222 - char* e = szBuffer + nBufLength;
223 + const char* p = szBuffer;
224 + const char* e = szBuffer + nBufLength;
225
226 while( p < e )
227 {
228 @@ -208,7 +208,8 @@
229 {
230 m_InHeaders = false;
231 ProcessHeaders();
232 - ProcessBody("", 0, true);
233 + /* type conversion should be safe as length is zero */
234 + ProcessBody((char *)"", 0, true);
235 }
236
237 return DKIM_SUCCESS;
238 @@ -338,9 +339,9 @@
239
240 CompressSWSP(sTemp);
241
242 - unsigned cpos = sTemp.find(':');
243 + string::size_type cpos = sTemp.find(':');
244
245 - if (cpos == -1)
246 + if (cpos == string::npos)
247 {
248 // no colon?!
249 }
250 diff -ru libdkim-1.0.19.orig/src/dkimbase.h libdkim-1.0.19/src/dkimbase.h
251 --- libdkim-1.0.19.orig/src/dkimbase.h 2008-05-12 20:07:24.000000000 +1000
252 +++ libdkim-1.0.19/src/dkimbase.h 2009-04-15 19:49:32.000000000 +1000
253 @@ -41,7 +41,7 @@
254
255 int Init(void);
256
257 - int Process( char* szBuffer, int nBufLength, bool bEOF );
258 + int Process( const char* szBuffer, int nBufLength, bool bEOF );
259 int ProcessFinal(void);
260
261 int Alloc( char*& szBuffer, int nRequiredSize );
262 diff -ru libdkim-1.0.19.orig/src/dkimsign.cpp libdkim-1.0.19/src/dkimsign.cpp
263 --- libdkim-1.0.19.orig/src/dkimsign.cpp 2008-05-12 20:07:46.000000000 +1000
264 +++ libdkim-1.0.19/src/dkimsign.cpp 2009-04-15 19:49:32.000000000 +1000
265 @@ -144,7 +144,7 @@
266
267 fwrite( szBuffer, 1, nBufLength, fpdebug );
268
269 - /** END DEBUG CODE **/
270 + ** END DEBUG CODE **/
271
272 if( bAllmanOnly )
273 {
274 @@ -555,7 +555,7 @@
275 // if bFold, fold at cbrk char
276 //
277 ////////////////////////////////////////////////////////////////////////////////
278 -void CDKIMSign::AddTagToSig( char* Tag, const string &sValue, char cbrk, bool bFold )
279 +void CDKIMSign::AddTagToSig( const char* const Tag, const string &sValue, char cbrk, bool bFold )
280 {
281 int nTagLen = strlen(Tag);
282
283 @@ -583,10 +583,10 @@
284 // AddTagToSig - add tag and numeric value to signature folding if necessary
285 //
286 ////////////////////////////////////////////////////////////////////////////////
287 -void CDKIMSign::AddTagToSig( char* Tag, unsigned long nValue )
288 +void CDKIMSign::AddTagToSig( const char* const Tag, unsigned long nValue )
289 {
290 char szValue[64];
291 - sprintf( szValue, "%u", nValue );
292 + sprintf( szValue, "%lu", nValue );
293 AddTagToSig( Tag, szValue, 0, false );
294 }
295
296 @@ -686,7 +686,7 @@
297 // GetSig - compute hash and return signature header in szSignature
298 //
299 ////////////////////////////////////////////////////////////////////////////////
300 -int CDKIMSign::GetSig( char* szPrivKey, char* szSignature, int nSigLength )
301 +int CDKIMSign::GetSig( char* szPrivKey, char* szSignature, unsigned nSigLength )
302 {
303 if( szPrivKey == NULL )
304 {
305 @@ -794,7 +794,6 @@
306 int size;
307 int len;
308 char* buf;
309 - int pos = 0;
310
311 // construct the DKIM-Signature: header and add to hash
312 InitSig();
313 @@ -879,7 +878,7 @@
314 }
315 BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
316 BIO_push(b64, bio);
317 - if (BIO_write(b64, Hash, nHashLen) < nHashLen)
318 + if (BIO_write(b64, Hash, nHashLen) < (int)nHashLen)
319 {
320 BIO_free_all(b64);
321 return DKIM_OUT_OF_MEMORY;
322 @@ -993,7 +992,7 @@
323 }
324 BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
325 BIO_push(b64, bio);
326 - if (BIO_write(b64, sig, siglen) < siglen)
327 + if (BIO_write(b64, sig, siglen) < (int)siglen)
328 {
329 OPENSSL_free(sig);
330 BIO_free_all(b64);
331 diff -ru libdkim-1.0.19.orig/src/dkimsign.h libdkim-1.0.19/src/dkimsign.h
332 --- libdkim-1.0.19.orig/src/dkimsign.h 2008-05-12 20:07:58.000000000 +1000
333 +++ libdkim-1.0.19/src/dkimsign.h 2009-04-15 19:49:32.000000000 +1000
334 @@ -32,7 +32,7 @@
335
336 int Init( DKIMSignOptions* pOptions );
337
338 - int GetSig( char* szPrivKey, char* szSignature, int nSigLength );
339 + int GetSig( char* szPrivKey, char* szSignature, unsigned nSigLength );
340 int GetSig2( char* szPrivKey, char** pszSignature );
341
342 virtual int ProcessHeaders(void);
343 @@ -50,8 +50,8 @@
344 bool ParseFromAddress( void );
345
346 void InitSig(void);
347 - void AddTagToSig( char* Tag, const string &sValue, char cbrk, bool bFold );
348 - void AddTagToSig( char* Tag, unsigned long nValue );
349 + void AddTagToSig( const char* const Tag, const string &sValue, char cbrk, bool bFold );
350 + void AddTagToSig( const char* const Tag, unsigned long nValue );
351 void AddInterTagSpace( int nSizeOfNextTag );
352 void AddFoldedValueToSig( const string &sValue, char cbrk );
353
354 diff -ru libdkim-1.0.19.orig/src/dkimverify.cpp libdkim-1.0.19/src/dkimverify.cpp
355 --- libdkim-1.0.19.orig/src/dkimverify.cpp 2009-04-15 19:37:48.000000000 +1000
356 +++ libdkim-1.0.19/src/dkimverify.cpp 2009-04-15 19:49:32.000000000 +1000
357 @@ -440,7 +440,7 @@
358 {
359 ProcessFinal();
360
361 - int SuccessCount=0;
362 + unsigned int SuccessCount=0;
363 int TestingFailures=0;
364 int RealFailures=0;
365
366 @@ -646,7 +646,7 @@
367 /** END DEBUG CODE **/
368 #endif
369
370 - if (IsBody && BodyLength != -1)
371 + if (IsBody && BodyLength != (unsigned)-1)
372 {
373 VerifiedBodyCount += nBufLength;
374 if (VerifiedBodyCount > BodyLength)
375 @@ -1019,7 +1019,7 @@
376 // body count
377 if (values[8] == NULL || !m_HonorBodyLengthTag)
378 {
379 - sig.BodyLength = -1;
380 + sig.BodyLength = (unsigned)-1;
381 }
382 else
383 {
384 @@ -1057,17 +1057,17 @@
385 // expiration time
386 if (values[11] == NULL)
387 {
388 - sig.ExpireTime = -1;
389 + sig.ExpireTime = (unsigned)-1;
390 }
391 else
392 {
393 if (!ParseUnsigned(values[11], &sig.ExpireTime))
394 return DKIM_BAD_SYNTAX;
395
396 - if (sig.ExpireTime != -1)
397 + if (sig.ExpireTime != (unsigned)-1)
398 {
399 // the value of x= MUST be greater than the value of t= if both are present
400 - if (SignedTime != -1 && sig.ExpireTime <= SignedTime)
401 + if (SignedTime != (unsigned)-1 && sig.ExpireTime <= SignedTime)
402 return DKIM_BAD_SYNTAX;
403
404 // todo: if possible, use the received date/time instead of the current time
405 @@ -1169,7 +1169,7 @@
406 }
407
408
409 -SelectorInfo::SelectorInfo(const string &sSelector, const string &sDomain) : Selector(sSelector), Domain(sDomain)
410 +SelectorInfo::SelectorInfo(const string &sSelector, const string &sDomain) : Domain(sDomain), Selector(sSelector)
411 {
412 AllowSHA1 = true;
413 AllowSHA256 = true;
414 @@ -1207,7 +1207,7 @@
415 return DKIM_SELECTOR_INVALID; // todo: maybe create a new error code for unsupported selector version
416
417 // make sure v= is the first tag in the response // todo: maybe don't enforce this, it seems unnecessary
418 - for (int j=1; j<sizeof(values)/sizeof(values[0]); j++)
419 + for (unsigned j=1; j<sizeof(values)/sizeof(values[0]); j++)
420 {
421 if (values[j] != NULL && values[j] < values[0])
422 {
423 diff -ru libdkim-1.0.19.orig/src/libdkimtest.cpp libdkim-1.0.19/src/libdkimtest.cpp
424 --- libdkim-1.0.19.orig/src/libdkimtest.cpp 2008-05-12 20:08:54.000000000 +1000
425 +++ libdkim-1.0.19/src/libdkimtest.cpp 2009-04-15 19:38:08.000000000 +1000
426 @@ -60,9 +60,9 @@
427 int main(int argc, char* argv[])
428 {
429 int n;
430 - char* PrivKeyFile = "test.pem";
431 - char* MsgFile = "test.msg";
432 - char* OutFile = "signed.msg";
433 + const char* PrivKeyFile = "test.pem";
434 + const char* MsgFile = "test.msg";
435 + const char* OutFile = "signed.msg";
436 int nPrivKeyLen;
437 char PrivKey[2048];
438 char Buffer[1024];
439
440
441
442 1.1 mail-filter/libdkim/files/patches/series
443
444 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/mail-filter/libdkim/files/patches/series?rev=1.1&view=markup
445 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/mail-filter/libdkim/files/patches/series?rev=1.1&content-type=text/plain
446
447 Index: series
448 ===================================================================
449 strtok_r.patch
450 fix_warnings.patch