?revision_form?Rev ?revision_input??revision_submit??revision_endform?
Rev 55 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#! /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@
--- a/src/dkim.cpp
+++ b/src/dkim.cpp
@@ -172,7 +172,7 @@ int DKIM_CALL DKIMVerifyInit( DKIMContex
}
-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 @@ void DKIM_CALL DKIMVerifyFree( DKIMConte
}
-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",
@@ -259,7 +259,7 @@ static char* DKIMErrorStrings[-1-DKIM_MA
};
-char* DKIM_CALL DKIMGetErrorString( int ErrorCode )
+const char* DKIM_CALL DKIMGetErrorString( int ErrorCode )
{
if (ErrorCode >= 0 || ErrorCode <= DKIM_MAX_ERROR)
return "Unknown";
--- a/src/dkim.h
+++ b/src/dkim.h
@@ -154,14 +154,14 @@ int DKIM_CALL DKIMSignGetSig2( DKIMConte
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
}
--- a/src/dkimbase.cpp
+++ b/src/dkimbase.cpp
@@ -118,10 +118,10 @@ void CDKIMBase::Free( char* szBuffer )
// 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 @@ int CDKIMBase::ProcessFinal(void)
{
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 @@ string CDKIMBase::RelaxHeader( const str
CompressSWSP(sTemp);
- unsigned cpos = sTemp.find(':');
+ string::size_type cpos = sTemp.find(':');
- if (cpos == -1)
+ if (cpos == string::npos)
{
// no colon?!
}
--- a/src/dkimbase.h
+++ b/src/dkimbase.h
@@ -41,7 +41,7 @@ public:
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 );
--- a/src/dkimsign.cpp
+++ b/src/dkimsign.cpp
@@ -144,7 +144,7 @@ void CDKIMSign::Hash( const char* szBuff
fwrite( szBuffer, 1, nBufLength, fpdebug );
- /** END DEBUG CODE **/
+ ** END DEBUG CODE **/
if( bAllmanOnly )
{
@@ -555,7 +555,7 @@ void CDKIMSign::InitSig(void)
// 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 @@ void CDKIMSign::AddTagToSig( char* Tag,
// 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 @@ void CDKIMSign::AddFoldedValueToSig( con
// 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 CDKIMSign::ConstructSignature( char*
int size;
int len;
char* buf;
- int pos = 0;
// construct the DKIM-Signature: header and add to hash
InitSig();
@@ -879,7 +878,7 @@ int CDKIMSign::ConstructSignature( char*
}
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 @@ int CDKIMSign::ConstructSignature( char*
}
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);
--- a/src/dkimsign.h
+++ b/src/dkimsign.h
@@ -32,7 +32,7 @@ public:
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 @@ protected:
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 );
--- a/src/dkimverify.cpp
+++ b/src/dkimverify.cpp
@@ -210,7 +210,7 @@ void DecodeQuotedPrintable(char *ptr)
////////////////////////////////////////////////////////////////////////////////
unsigned DecodeBase64(char *ptr)
{
- static const unsigned char base64_table[256] = {
+ static const signed char base64_table[256] = {
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,
-1, 0, 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,-1,-1,-1,-1,-1,
@@ -227,10 +227,10 @@ unsigned DecodeBase64(char *ptr)
while (*s != '\0')
{
- unsigned char value = base64_table[*s++];
- if ( (signed char)value >= 0 )
+ signed char value = base64_table[*s++];
+ if ( value >= 0 )
{
- b64accum = (b64accum << 6) | value;
+ b64accum = (b64accum << 6) | (unsigned char)value;
b64shift += 6;
if (b64shift >= 8)
{
@@ -442,7 +442,7 @@ int CDKIMVerify::GetResults(void)
{
ProcessFinal();
- int SuccessCount=0;
+ unsigned int SuccessCount=0;
int TestingFailures=0;
int RealFailures=0;
@@ -643,7 +643,7 @@ void SignatureInfo::Hash( const char* sz
/** END DEBUG CODE **/
#endif
- if (IsBody && BodyLength != -1)
+ if (IsBody && BodyLength != (unsigned)-1)
{
VerifiedBodyCount += nBufLength;
if (VerifiedBodyCount > BodyLength)
@@ -1050,7 +1050,7 @@ int CDKIMVerify::ParseDKIMSignature( con
// body count
if (values[8] == NULL || !m_HonorBodyLengthTag)
{
- sig.BodyLength = -1;
+ sig.BodyLength = (unsigned)-1;
}
else
{
@@ -1088,17 +1088,17 @@ int CDKIMVerify::ParseDKIMSignature( con
// 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
@@ -1200,7 +1200,7 @@ int CDKIMVerify::ProcessBody( char* szBu
}
-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;
@@ -1241,7 +1241,7 @@ int SelectorInfo::Parse( char* Buffer )
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])
{
--- a/src/libdkimtest.cpp
+++ b/src/libdkimtest.cpp
@@ -60,9 +60,9 @@ int DKIM_CALL SelectorCallback(const cha
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];