From cb9bff92107d168ff6dd0c12dc34bc7bacc8eb7d Mon Sep 17 00:00:00 2001 From: Jannis Hoffmann Date: Wed, 3 Jul 2024 23:33:05 +0200 Subject: remove "using namespace std" from cpp headers --- src/dkimverify.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/dkimverify.cpp') diff --git a/src/dkimverify.cpp b/src/dkimverify.cpp index 334e1b4..90f871f 100644 --- a/src/dkimverify.cpp +++ b/src/dkimverify.cpp @@ -37,6 +37,8 @@ extern "C" { #include "dns.h" } +using std::string; + /***************************************************************************** * * Verifying DKIM Ed25519 signatures: @@ -413,7 +415,7 @@ bool WildcardMatch(const char *p, const char *s) // Parse addresses from a string. Returns true if at least one address found // //////////////////////////////////////////////////////////////////////////////// -bool ParseAddresses(string str, vector& Addresses) +bool ParseAddresses(string str, std::vector& Addresses) { char *s = (char *)str.c_str(); @@ -555,9 +557,9 @@ int CDKIMVerify::GetResults(void) int RealFailures = 0; int res = 0; - list SuccessfulDomains; // can contain duplicates + std::list SuccessfulDomains; // can contain duplicates - for (list::iterator i = Signatures.begin(); i != Signatures.end(); ++i) { + for (std::list::iterator i = Signatures.begin(); i != Signatures.end(); ++i) { if (i->Status == DKIM_SUCCESS) { if (!i->BodyHashData.empty()) { // FIRST: Get the body hash unsigned char md[EVP_MAX_MD_SIZE]; @@ -678,13 +680,13 @@ int CDKIMVerify::GetResults(void) // get the From address's domain if we might need it string sFromDomain; if (SuccessCount > 0 || m_CheckPractices) { - for (list::iterator i = HeaderList.begin(); i != HeaderList.end(); ++i) { + for (std::list::iterator i = HeaderList.begin(); i != HeaderList.end(); ++i) { if (_strnicmp(i->c_str(), "From", 4) == 0) { // skip over whitespace between the header name and : const char *s = i->c_str() + 4; while (*s == ' ' || *s == '\t') s++; if (*s == ':') { - vector Addresses; + std::vector Addresses; if (ParseAddresses(s + 1, Addresses)) { unsigned atpos = Addresses[0].find('@'); sFromDomain = Addresses[0].substr(atpos + 1); @@ -698,7 +700,7 @@ int CDKIMVerify::GetResults(void) // if a signature from the From domain verified successfully, return success now // without checking the author domain signing practices if (SuccessCount > 0 && !sFromDomain.empty()) { - for (list::iterator i = SuccessfulDomains.begin(); i != SuccessfulDomains.end(); ++i) { + for (std::list::iterator i = SuccessfulDomains.begin(); i != SuccessfulDomains.end(); ++i) { // see if the successful domain is the same as or a parent of the From domain if (i->length() > sFromDomain.length()) continue; if (_stricmp(i->c_str(), sFromDomain.c_str() + sFromDomain.length() - i->length()) != 0) continue; @@ -779,7 +781,7 @@ void SignatureInfo::Hash(const char *szBuffer, unsigned nBufLength, bool IsBody) //////////////////////////////////////////////////////////////////////////////// int CDKIMVerify::ProcessHeaders(void) { - for (list::iterator i = HeaderList.begin(); i != HeaderList.end(); ++i) { + for (std::list::iterator i = HeaderList.begin(); i != HeaderList.end(); ++i) { if (strlen(i->c_str()) < 14) continue; // too short if (_strnicmp(i->c_str(), "DKIM-Signature", 14) == 0) { // skip over whitespace between the header name and : @@ -800,7 +802,7 @@ int CDKIMVerify::ProcessHeaders(void) bool ValidSigFound = false; - for (list::iterator s = Signatures.begin(); s != Signatures.end(); ++s) { + for (std::list::iterator s = Signatures.begin(); s != Signatures.end(); ++s) { SignatureInfo& sig = *s; if (sig.Status != DKIM_SUCCESS) continue; SelectorInfo& sel = GetSelector(sig.Selector, sig.Domain); @@ -854,10 +856,11 @@ int CDKIMVerify::ProcessHeaders(void) #endif // compute the hash of the header - vector::reverse_iterator> used; + std::vector::reverse_iterator> used; - for (vector::iterator x = sig.SignedHeaders.begin(); x != sig.SignedHeaders.end(); ++x) { - list::reverse_iterator i; + for (std::vector::iterator x = sig.SignedHeaders.begin(); x != sig.SignedHeaders.end(); ++x) + { + std::list::reverse_iterator i; for (i = HeaderList.rbegin(); i != HeaderList.rend(); ++i) { if (_strnicmp(i->c_str(), x->c_str(), x->length()) == 0) { // skip over whitespace between the header name and : @@ -897,7 +900,7 @@ int CDKIMVerify::ProcessHeaders(void) if (!m_AllowUnsignedFromHeaders) { // make sure the message has no unsigned From headers - list::reverse_iterator i; + std::list::reverse_iterator i; for (i = HeaderList.rbegin(); i != HeaderList.rend(); ++i) { if (_strnicmp(i->c_str(), "From", 4) == 0) { // skip over whitespace between the header name and : @@ -1143,7 +1146,7 @@ int CDKIMVerify::ProcessBody(char *szBuffer, int nBufLength, bool bEOF) { bool MoreBodyNeeded = false; - for (list::iterator i = Signatures.begin(); i != Signatures.end(); ++i) { + for (std::list::iterator i = Signatures.begin(); i != Signatures.end(); ++i) { if (i->Status == DKIM_SUCCESS) { if (i->BodyCanonicalization == DKIM_CANON_SIMPLE) { if (nBufLength > 0) { @@ -1351,7 +1354,7 @@ int SelectorInfo::Parse(char *Buffer) SelectorInfo& CDKIMVerify::GetSelector(const string& sSelector, const string& sDomain) { // see if we already have this selector - for (list::iterator i = Selectors.begin(); i != Selectors.end(); ++i) { + for (std::list::iterator i = Selectors.begin(); i != Selectors.end(); ++i) { if (_stricmp(i->Selector.c_str(), sSelector.c_str()) == 0 && _stricmp(i->Domain.c_str(), sDomain.c_str()) == 0) { @@ -1401,7 +1404,7 @@ int CDKIMVerify::GetDetails(int *nSigCount, DKIMVerifyDetails **pDetails) { Details.clear(); - for (list::iterator i = Signatures.begin(); i != Signatures.end(); ++i) { + for (std::list::iterator i = Signatures.begin(); i != Signatures.end(); ++i) { DKIMVerifyDetails d; d.szSignature = (char *)i->Header.c_str(); d.szSignatureDomain = (char *)i->Domain.c_str(); -- cgit v1.2.3