OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

320 lines
11 KiB

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