From 8645d67d1094dbfa87f900f753617ecc199a8a97 Mon Sep 17 00:00:00 2001 From: Paul Herzog Date: Wed, 7 May 2014 12:18:05 -0400 Subject: [PATCH 1/3] Made implicit typecasts explicit to eliminate compiler warnings --- bnlib/bnprint.c | 2 +- bnlib/ec/ec.c | 27 +++++------ clients/tivi/CtZrtpStream.cpp | 14 +++--- clients/tivi/TiviTimeoutProvider.h | 4 +- common/Thread.cpp | 6 +-- srtp/CryptoContext.cpp | 4 +- srtp/SrtpHandler.cpp | 16 +++---- zrtp/Base32.cpp | 10 ++-- zrtp/ZIDCacheDb.cpp | 4 +- zrtp/ZIDRecordDb.cpp | 4 +- zrtp/ZIDRecordFile.cpp | 4 +- zrtp/ZRtp.cpp | 54 +++++++++++----------- zrtp/ZrtpCWrapper.cpp | 2 +- zrtp/ZrtpConfigure.cpp | 2 +- zrtp/ZrtpSdesStream.cpp | 10 ++-- zrtp/libzrtpcpp/Base32.h | 2 +- zrtp/libzrtpcpp/ZrtpCWrapper.h | 2 +- zrtp/zrtpB64Decode.c | 8 ++-- zrtp/zrtpB64Encode.c | 8 ++-- zrtp/zrtpCacheSqliteBackend.c | 74 +++++++++++++++--------------- 20 files changed, 129 insertions(+), 128 deletions(-) diff --git a/bnlib/bnprint.c b/bnlib/bnprint.c index a4072484..59c9b6a2 100644 --- a/bnlib/bnprint.c +++ b/bnlib/bnprint.c @@ -99,7 +99,7 @@ static int getAsciiDigit( uint32_t *d, int radix, char c ) int bnReadAscii(struct BigNum *X, char *s, int radix) { - int slen = strlen(s); + int slen = (int)strlen(s); int i, neg = 0; uint32_t d; diff --git a/bnlib/ec/ec.c b/bnlib/ec/ec.c index 18e612f8..4c315bc3 100644 --- a/bnlib/ec/ec.c +++ b/bnlib/ec/ec.c @@ -284,14 +284,14 @@ static void curveCommonPrealloc(EcCurve *curve) /* The set_bit allocates enough memory to hold maximum values */ /* Initialize scratchpad variables before use */ - bnPrealloc(curve->S1, maxBits); - bnPrealloc(curve->U1, maxBits); - bnPrealloc(curve->H, maxBits); - bnPrealloc(curve->R, maxBits); - bnPrealloc(curve->S1, maxBits); - bnPrealloc(curve->t1, maxBits); - bnPrealloc(curve->t2, maxBits); - bnPrealloc(curve->t3, maxBits); + bnPrealloc(curve->S1, (unsigned int)maxBits); + bnPrealloc(curve->U1, (unsigned int)maxBits); + bnPrealloc(curve->H, (unsigned int)maxBits); + bnPrealloc(curve->R, (unsigned int)maxBits); + bnPrealloc(curve->S1, (unsigned int)maxBits); + bnPrealloc(curve->t1, (unsigned int)maxBits); + bnPrealloc(curve->t2, (unsigned int)maxBits); + bnPrealloc(curve->t3, (unsigned int)maxBits); } int ecGetCurveNistECp(Curves curveId, EcCurve *curve) @@ -332,6 +332,7 @@ int ecGetCurveNistECp(Curves curveId, EcCurve *curve) case NIST256P: cd = &nist256; + curve->modOp = newMod256; // avoids unused function warning curve->modOp = bnMod; break; @@ -980,7 +981,7 @@ static int _random(unsigned char *output, size_t len) #include static int _random(unsigned char *output, size_t len) { - return zrtp_getRandomData(output, len); + return zrtp_getRandomData(output, (uint32_t)len); } #endif @@ -1008,7 +1009,7 @@ static int ecGenerateRandomNumberNist(const EcCurve *curve, BigNum *d) while (!bnCmpQ(d, 0)) { /* use _random function */ _random(ran, randomBytes); - bnInsertBigBytes(&c, ran, 0, randomBytes); + bnInsertBigBytes(&c, ran, 0, (unsigned int)randomBytes); bnMod(d, &c, &nMinusOne); bnAddMod_(d, mpiOne, curve->p); } @@ -1671,11 +1672,11 @@ static int newMod521(BigNum *r, const BigNum *a, const BigNum *modulo) } modSize = bnBytes(modulo); - bnExtractBigBytes(a, buf1, 0, modSize*2); /* a must be less modulo^2 */ + bnExtractBigBytes(a, buf1, 0, (unsigned int)modSize*2); /* a must be less modulo^2 */ buf1[modSize] &= 1; /* clear all bits except least significat */ bnRShift(r, 521); - bnExtractBigBytes(r, buf2, 0, modSize*2); + bnExtractBigBytes(r, buf2, 0, (unsigned int)modSize*2); buf2[modSize] &= 1; p1 = &buf2[131]; /* p1 is pointer to A0 */ @@ -1685,7 +1686,7 @@ static int newMod521(BigNum *r, const BigNum *a, const BigNum *modulo) ac += *p1 + *p2--; *p1-- = ac; ac >>= 8; } bnSetQ(r, 0); - bnInsertBigBytes(r, p1+1, 0, modSize); + bnInsertBigBytes(r, p1+1, 0, (unsigned int)modSize); while (bnCmp(r, modulo) >= 0) { bnSub(r, modulo); diff --git a/clients/tivi/CtZrtpStream.cpp b/clients/tivi/CtZrtpStream.cpp index db3cd8e2..f81ff3ec 100644 --- a/clients/tivi/CtZrtpStream.cpp +++ b/clients/tivi/CtZrtpStream.cpp @@ -26,9 +26,9 @@ // #define DEBUG_CTSTREAM #ifdef DEBUG_CTSTREAM static char debBuf[500]; -#define DEBUG(deb) deb +#define T_DEBUG(deb) deb #else -#define DEBUG(deb) +#define T_DEBUG(deb) #endif static TimeoutProvider* staticTimeoutProvider = NULL; @@ -176,7 +176,7 @@ bool CtZrtpStream::processOutgoingRtp(uint8_t *buffer, size_t length, size_t *ne // Do not send in states: CommitSent, WaitDHPart2, WaitConfirm1, WaitConfirm2, WaitConfAck if (started && (zrtpEngine->inState(CommitSent) || zrtpEngine->inState(WaitDHPart2) || zrtpEngine->inState(WaitConfirm1) || zrtpEngine->inState(WaitConfirm2) || zrtpEngine->inState(WaitConfAck))) { - ZrtpRandom::addEntropy(buffer, length); + ZrtpRandom::addEntropy(buffer, (uint32_t)length); return false; } if (useSdesForMedia && sdes != NULL) { // SDES stream available, let SDES protect if necessary @@ -305,7 +305,7 @@ int32_t CtZrtpStream::processIncomingRtp(uint8_t *buffer, const size_t length, s useLength = newLength + CRC_SIZE; // length check assumes a ZRTP CRC } else { - DEBUG(char tmpBuffer[500];) + T_DEBUG(char tmpBuffer[500];) useZrtpTunnel = false; // Get CRC value into crc (see above how to compute the offset) uint16_t temp = length - CRC_SIZE; @@ -314,7 +314,7 @@ int32_t CtZrtpStream::processIncomingRtp(uint8_t *buffer, const size_t length, s if (!zrtpCheckCksum(buffer, temp, crc)) { zrtpCrcErrors++; if (zrtpCrcErrors > 15) { - DEBUG(snprintf(debBuf, 499, "len: %d, sdes: %p, sdesMedia: %d, zrtpEncap: %d", temp, (void*)sdes, useSdesForMedia, zrtpEncapSignaled); zrtp_log("CtZrtpStream", debBuf);) + T_DEBUG(snprintf(debBuf, 499, "len: %d, sdes: %p, sdesMedia: %d, zrtpEncap: %d", temp, (void*)sdes, useSdesForMedia, zrtpEncapSignaled); zrtp_log("CtZrtpStream", debBuf);) sendInfo(Warning, WarningCRCmismatch); zrtpCrcErrors = 0; @@ -343,7 +343,7 @@ int CtZrtpStream::getSignalingHelloHash(char *hHash, int32_t index) { std::string hash; hash = zrtpEngine->getHelloHash(index); strcpy(hHash, hash.c_str()); - return hash.size(); + return (int)hash.size(); } void CtZrtpStream::setSignalingHelloHash(const char *hHash) { @@ -418,7 +418,7 @@ int CtZrtpStream::getInfo(const char *key, char *p, int maxLen) { const ZRtp::zrtpInfo *info = NULL; ZRtp::zrtpInfo tmpInfo; - int iLen = strlen(key); + int iLen = (int)strlen(key); // set the security state as a combination of tivi state and stateflags int secState = tiviState & 0xff; diff --git a/clients/tivi/TiviTimeoutProvider.h b/clients/tivi/TiviTimeoutProvider.h index d7b9bb5a..c7f630b3 100644 --- a/clients/tivi/TiviTimeoutProvider.h +++ b/clients/tivi/TiviTimeoutProvider.h @@ -250,9 +250,9 @@ class TimeoutProvider : public CThread { do { synchLock.Lock(); int32_t time = 3600000; - int32_t size = 0; + int32_t size = (int32_t)requests.size(); - if ((size = requests.size()) > 0) { + if (size > 0) { time = requests.front()->getMsToTimeout(); } if (time == 0 && size > 0) { diff --git a/common/Thread.cpp b/common/Thread.cpp index 307eaa7f..62e73d70 100644 --- a/common/Thread.cpp +++ b/common/Thread.cpp @@ -200,7 +200,7 @@ _THKERNEL( LPVOID lpvData /* CThread Object */ } */ if( pThread->m_type == ThreadTypeIntervalDriven ) - Sleep(pThread->m_dwIdle); + Sleep((unsigned int)pThread->m_dwIdle); } @@ -717,7 +717,7 @@ CThread::Pop() { m_mutex.Lock(); - if( m_queuePos-1 < 0 ) + if( (int)m_queuePos-1 < 0 ) { m_queuePos = 0; m_dwObjectCondition |= STACK_EMPTY; @@ -1071,7 +1071,7 @@ CThread::PingThread(DWORD dwTimeout /* timeout in milli-seconds */ } dwTotal += m_dwIdle; m_mutex.Unlock(); - Sleep(m_dwIdle); + Sleep((unsigned int)m_dwIdle); } return FALSE; diff --git a/srtp/CryptoContext.cpp b/srtp/CryptoContext.cpp index 9fb6a119..e1441c18 100644 --- a/srtp/CryptoContext.cpp +++ b/srtp/CryptoContext.cpp @@ -398,7 +398,7 @@ bool CryptoContext::checkReplay(uint16_t newSeq) } delta = -delta; - int idx = delta / 64; + int idx = (int)(delta / 64); uint64_t bit = 1UL << (delta % 64); if ((replay_window[idx] & bit) == bit) { return false; /* Packet already received ! */ @@ -447,7 +447,7 @@ void CryptoContext::update(uint16_t newSeq) } else { delta = -delta; - int idx = delta / 64; + int idx = (int)(delta / 64); uint64_t bit = 1UL << (delta % 64); replay_window[idx] |= bit; } diff --git a/srtp/SrtpHandler.cpp b/srtp/SrtpHandler.cpp index 621e25a9..b7c77e48 100644 --- a/srtp/SrtpHandler.cpp +++ b/srtp/SrtpHandler.cpp @@ -94,7 +94,7 @@ bool SrtpHandler::protect(CryptoContext* pcc, uint8_t* buffer, size_t length, si if (pcc == NULL) { return false; } - if (!decodeRtp(buffer, length, &ssrc, &seqnum, &payload, &payloadlen)) + if (!decodeRtp(buffer, (int32_t)length, &ssrc, &seqnum, &payload, &payloadlen)) return false; /* Encrypt the packet */ @@ -107,7 +107,7 @@ bool SrtpHandler::protect(CryptoContext* pcc, uint8_t* buffer, size_t length, si /* Compute MAC and store at end of RTP packet data */ if (pcc->getTagLength() > 0) { - pcc->srtpAuthenticate(buffer, length, pcc->getRoc(), buffer+length); + pcc->srtpAuthenticate(buffer, (int32_t)length, pcc->getRoc(), buffer+length); } *newLength = length + pcc->getTagLength(); @@ -129,7 +129,7 @@ int32_t SrtpHandler::unprotect(CryptoContext* pcc, uint8_t* buffer, size_t lengt return 0; } - if (!decodeRtp(buffer, length, &ssrc, &seqnum, &payload, &payloadlen)) + if (!decodeRtp(buffer, (int32_t)length, &ssrc, &seqnum, &payload, &payloadlen)) return 0; /* * This is the setting of the packet data when we come to this point: @@ -142,7 +142,7 @@ int32_t SrtpHandler::unprotect(CryptoContext* pcc, uint8_t* buffer, size_t lengt * The SRTP MKI and authentication data is always at the end of a * packet. Thus compute the position of this data. */ - uint32_t srtpDataIndex = length - (pcc->getTagLength() + pcc->getMkiLength()); + uint32_t srtpDataIndex = (uint32_t)(length - (pcc->getTagLength() + pcc->getMkiLength())); // Compute new length length -= pcc->getTagLength() + pcc->getMkiLength(); @@ -163,7 +163,7 @@ int32_t SrtpHandler::unprotect(CryptoContext* pcc, uint8_t* buffer, size_t lengt uint64_t guessedIndex = pcc->guessIndex(seqnum); if (pcc->getTagLength() > 0) { - uint32_t guessedRoc = guessedIndex >> 16; + uint32_t guessedRoc = (uint32_t)(guessedIndex >> 16); uint8_t mac[20]; pcc->srtpAuthenticate(buffer, (uint32_t)length, guessedRoc, mac); @@ -192,7 +192,7 @@ bool SrtpHandler::protectCtrl(CryptoContextCtrl* pcc, uint8_t* buffer, size_t le ssrc = zrtpNtohl(ssrc); uint32_t encIndex = pcc->getSrtcpIndex(); - pcc->srtcpEncrypt(buffer + 8, length - 8, encIndex, ssrc); + pcc->srtcpEncrypt(buffer + 8, (int32_t)length - 8, encIndex, ssrc); encIndex |= 0x80000000; // set the E flag @@ -204,7 +204,7 @@ bool SrtpHandler::protectCtrl(CryptoContextCtrl* pcc, uint8_t* buffer, size_t le // take MKI length into account when storing the authentication tag. // Compute MAC and store in packet after the SRTCP index field - pcc->srtcpAuthenticate(buffer, length, encIndex, buffer + length + sizeof(uint32_t)); + pcc->srtcpAuthenticate(buffer, (int32_t)length, encIndex, buffer + length + sizeof(uint32_t)); encIndex++; encIndex &= ~0x80000000; // clear the E-flag and modulo 2^31 @@ -222,7 +222,7 @@ int32_t SrtpHandler::unprotectCtrl(CryptoContextCtrl* pcc, uint8_t* buffer, size } // Compute the total length of the payload - int32_t payloadLen = length - (pcc->getTagLength() + pcc->getMkiLength() + 4); + int32_t payloadLen = (int32_t)length - (pcc->getTagLength() + pcc->getMkiLength() + 4); *newLength = payloadLen; // point to the SRTCP index field just after the real payload diff --git a/zrtp/Base32.cpp b/zrtp/Base32.cpp index ccc8034b..2bf7020a 100644 --- a/zrtp/Base32.cpp +++ b/zrtp/Base32.cpp @@ -125,7 +125,7 @@ void Base32::b2a_l(const unsigned char* os, int len, /* index into the result buffer, initially pointing to the * "one-past-the-end" quintet */ - int resp = result.size(); + int resp = (int)result.size(); /* pointer into the os buffer, initially pointing to the * "one-past-the-end" octet @@ -170,14 +170,14 @@ void Base32::b2a_l(const unsigned char* os, int len, } /* switch ((osp - os.buf) % 5) */ /* truncate any unused trailing zero quintets */ - encoded = result.substr(0, divceil(lengthinbits, 5)); + encoded = result.substr(0, divceil((int)lengthinbits, 5)); return; } void Base32::a2b_l(const string cs, size_t size, const size_t lengthinbits ) { unsigned long x = 0; // to hold up to 32 bits worth of the input - int len = divceil(size*5, 8); + int len = divceil((int)size*5, 8); /* if lengthinbits is not a multiple of 5 then this is * allocating space for 0 or 1 extra octets that will be @@ -200,7 +200,7 @@ void Base32::a2b_l(const string cs, size_t size, const size_t lengthinbits ) { /* index into the input buffer, initially pointing to the * "one-past-the-end" character */ - int csp = size; + int csp = (int)size; /* Now this is a real live Duff's device. You gotta love it. */ switch (csp % 8) { @@ -234,7 +234,7 @@ void Base32::a2b_l(const string cs, size_t size, const size_t lengthinbits ) { } /* switch ((csp - cs.buf) % 8) */ /* truncate any unused trailing zero octets */ - resultLength = divceil(lengthinbits, 8); + resultLength = divceil((int)lengthinbits, 8); return; } diff --git a/zrtp/ZIDCacheDb.cpp b/zrtp/ZIDCacheDb.cpp index 579bfb8c..d0917645 100644 --- a/zrtp/ZIDCacheDb.cpp +++ b/zrtp/ZIDCacheDb.cpp @@ -108,7 +108,7 @@ int32_t ZIDCacheDb::getPeerName(const uint8_t *peerZid, std::string *name) { return 0; } name->assign(buffer); - return name->length(); + return (int32_t)name->length(); } void ZIDCacheDb::putPeerName(const uint8_t *peerZid, const std::string name) { @@ -120,7 +120,7 @@ void ZIDCacheDb::putPeerName(const uint8_t *peerZid, const std::string name) { cacheOps.readZidNameRecord(zidFile, peerZid, associatedZid, NULL, &nameRec, errorBuffer); nameRec.name = (char*)name.c_str(); - nameRec.nameLength = name.length(); + nameRec.nameLength = (int32_t)name.length(); nameRec.nameLength = nameRec.nameLength > 200 ? 200 : nameRec.nameLength; if ((nameRec.flags & Valid) != Valid) { nameRec.flags = Valid; diff --git a/zrtp/ZIDRecordDb.cpp b/zrtp/ZIDRecordDb.cpp index b097cbfa..e308b1ab 100644 --- a/zrtp/ZIDRecordDb.cpp +++ b/zrtp/ZIDRecordDb.cpp @@ -52,7 +52,7 @@ bool ZIDRecordDb::isRs1NotExpired() { time_t current = time(NULL); time_t validThru; - validThru = record.rs1Ttl; + validThru = (time_t)record.rs1Ttl; if (validThru == -1) return true; @@ -65,7 +65,7 @@ bool ZIDRecordDb::isRs2NotExpired() { time_t current = time(NULL); time_t validThru; - validThru = record.rs2Ttl; + validThru = (time_t)record.rs2Ttl; if (validThru == -1) return true; diff --git a/zrtp/ZIDRecordFile.cpp b/zrtp/ZIDRecordFile.cpp index fd25dec1..e64d6ece 100644 --- a/zrtp/ZIDRecordFile.cpp +++ b/zrtp/ZIDRecordFile.cpp @@ -62,7 +62,7 @@ bool ZIDRecordFile::isRs1NotExpired() { if (sizeof(time_t) == 4) { long long temp; memcpy((unsigned char*)&temp, record.rs1Interval, TIME_LENGTH); - validThru = temp; + validThru = (time_t)temp; } else { memcpy((unsigned char*)&validThru, record.rs1Interval, TIME_LENGTH); @@ -82,7 +82,7 @@ bool ZIDRecordFile::isRs2NotExpired() { if (sizeof(time_t) == 4) { long long temp; memcpy((unsigned char*)&temp, record.rs2Interval, TIME_LENGTH); - validThru = temp; + validThru = (time_t)temp; } else { memcpy((unsigned char*)&validThru, record.rs2Interval, TIME_LENGTH); diff --git a/zrtp/ZRtp.cpp b/zrtp/ZRtp.cpp index c7d2a464..be36df1d 100755 --- a/zrtp/ZRtp.cpp +++ b/zrtp/ZRtp.cpp @@ -1774,37 +1774,37 @@ void ZRtp:: computeSharedSecretSet(ZIDRecord *zidRec) { detailInfo.secretsCached = 0; if (!zidRec->isRs1Valid()) { randomZRTP(randBuf, RS_LENGTH); - hmacFunction(randBuf, RS_LENGTH, (unsigned char*)initiator, strlen(initiator), rs1IDi, &macLen); - hmacFunction(randBuf, RS_LENGTH, (unsigned char*)responder, strlen(responder), rs1IDr, &macLen); + hmacFunction(randBuf, RS_LENGTH, (unsigned char*)initiator, (int32_t)strlen(initiator), rs1IDi, &macLen); + hmacFunction(randBuf, RS_LENGTH, (unsigned char*)responder, (int32_t)strlen(responder), rs1IDr, &macLen); } else { rs1Valid = true; - hmacFunction((unsigned char*)zidRec->getRs1(), RS_LENGTH, (unsigned char*)initiator, strlen(initiator), rs1IDi, &macLen); - hmacFunction((unsigned char*)zidRec->getRs1(), RS_LENGTH, (unsigned char*)responder, strlen(responder), rs1IDr, &macLen); + hmacFunction((unsigned char*)zidRec->getRs1(), RS_LENGTH, (unsigned char*)initiator, (int32_t)strlen(initiator), rs1IDi, &macLen); + hmacFunction((unsigned char*)zidRec->getRs1(), RS_LENGTH, (unsigned char*)responder, (int32_t)strlen(responder), rs1IDr, &macLen); detailInfo.secretsCached = Rs1; } if (!zidRec->isRs2Valid()) { randomZRTP(randBuf, RS_LENGTH); - hmacFunction(randBuf, RS_LENGTH, (unsigned char*)initiator, strlen(initiator), rs2IDi, &macLen); - hmacFunction(randBuf, RS_LENGTH, (unsigned char*)responder, strlen(responder), rs2IDr, &macLen); + hmacFunction(randBuf, RS_LENGTH, (unsigned char*)initiator, (int32_t)strlen(initiator), rs2IDi, &macLen); + hmacFunction(randBuf, RS_LENGTH, (unsigned char*)responder, (int32_t)strlen(responder), rs2IDr, &macLen); } else { rs2Valid = true; - hmacFunction((unsigned char*)zidRec->getRs2(), RS_LENGTH, (unsigned char*)initiator, strlen(initiator), rs2IDi, &macLen); - hmacFunction((unsigned char*)zidRec->getRs2(), RS_LENGTH, (unsigned char*)responder, strlen(responder), rs2IDr, &macLen); + hmacFunction((unsigned char*)zidRec->getRs2(), RS_LENGTH, (unsigned char*)initiator, (int32_t)strlen(initiator), rs2IDi, &macLen); + hmacFunction((unsigned char*)zidRec->getRs2(), RS_LENGTH, (unsigned char*)responder, (int32_t)strlen(responder), rs2IDr, &macLen); detailInfo.secretsCached |= Rs2; } if (!zidRec->isMITMKeyAvailable()) { randomZRTP(randBuf, RS_LENGTH); - hmacFunction(randBuf, RS_LENGTH, (unsigned char*)initiator, strlen(initiator), pbxSecretIDi, &macLen); - hmacFunction(randBuf, RS_LENGTH, (unsigned char*)responder, strlen(responder), pbxSecretIDr, &macLen); + hmacFunction(randBuf, RS_LENGTH, (unsigned char*)initiator, (int32_t)strlen(initiator), pbxSecretIDi, &macLen); + hmacFunction(randBuf, RS_LENGTH, (unsigned char*)responder, (int32_t)strlen(responder), pbxSecretIDr, &macLen); } else { - hmacFunction((unsigned char*)zidRec->getMiTMData(), RS_LENGTH, (unsigned char*)initiator, strlen(initiator), pbxSecretIDi, &macLen); - hmacFunction((unsigned char*)zidRec->getMiTMData(), RS_LENGTH, (unsigned char*)responder, strlen(responder), pbxSecretIDr, &macLen); + hmacFunction((unsigned char*)zidRec->getMiTMData(), RS_LENGTH, (unsigned char*)initiator, (int32_t)strlen(initiator), pbxSecretIDi, &macLen); + hmacFunction((unsigned char*)zidRec->getMiTMData(), RS_LENGTH, (unsigned char*)responder, (int32_t)strlen(responder), pbxSecretIDr, &macLen); detailInfo.secretsCached |= Pbx; } computeAuxSecretIds(); @@ -1944,7 +1944,7 @@ void ZRtp::generateKeysInitiator(ZrtpPacketDHPart *dhPart, ZIDRecord *zidRec) { // Next the fixed string "ZRTP-HMAC-KDF" data[pos] = (unsigned char*)KDFString; - length[pos++] = strlen(KDFString); + length[pos++] = (unsigned int)strlen(KDFString); // Next is Initiator's id (ZIDi), in this case as Initiator // it is zid @@ -2109,7 +2109,7 @@ void ZRtp::generateKeysResponder(ZrtpPacketDHPart *dhPart, ZIDRecord *zidRec) { // Next the fixed string "ZRTP-HMAC-KDF" data[pos] = (unsigned char*)KDFString; - length[pos++] = strlen(KDFString); + length[pos++] = (unsigned int)strlen(KDFString); // Next is Initiator's id (ZIDi), in this case as Responder // it is peerZid @@ -2214,7 +2214,7 @@ void ZRtp::generateKeysMultiStream() { } memcpy(KDFcontext+sizeof(ownZid)+sizeof(peerZid), messageHash, hashLength); - KDF(zrtpSession, hashLength, (unsigned char*)zrtpMsk, strlen(zrtpMsk)+1, KDFcontext, kdfSize, hashLength*8, s0); + KDF(zrtpSession, hashLength, (unsigned char*)zrtpMsk, (int32_t)strlen(zrtpMsk)+1, KDFcontext, kdfSize, hashLength*8, s0); memset(KDFcontext, 0, sizeof(KDFcontext)); @@ -2236,7 +2236,7 @@ void ZRtp::computePBXSecret() { memcpy(KDFcontext+sizeof(ownZid), peerZid, sizeof(peerZid)); } - KDF(zrtpSession, hashLength, (unsigned char*)zrtpTrustedMitm, strlen(zrtpTrustedMitm)+1, KDFcontext, + KDF(zrtpSession, hashLength, (unsigned char*)zrtpTrustedMitm, (int32_t)strlen(zrtpTrustedMitm)+1, KDFcontext, kdfSize, SHA256_DIGEST_LENGTH * 8, pbxSecretTmpBuffer); pbxSecretTmp = pbxSecretTmpBuffer; // set pointer to buffer, signal PBX secret was computed @@ -2262,34 +2262,34 @@ void ZRtp::computeSRTPKeys() { memcpy(KDFcontext+sizeof(ownZid)+sizeof(peerZid), messageHash, hashLength); // Inititiator key and salt - KDF(s0, hashLength, (unsigned char*)iniMasterKey, strlen(iniMasterKey)+1, KDFcontext, kdfSize, keyLen, srtpKeyI); - KDF(s0, hashLength, (unsigned char*)iniMasterSalt, strlen(iniMasterSalt)+1, KDFcontext, kdfSize, 112, srtpSaltI); + KDF(s0, hashLength, (unsigned char*)iniMasterKey, (int32_t)strlen(iniMasterKey)+1, KDFcontext, kdfSize, keyLen, srtpKeyI); + KDF(s0, hashLength, (unsigned char*)iniMasterSalt, (int32_t)strlen(iniMasterSalt)+1, KDFcontext, kdfSize, 112, srtpSaltI); // Responder key and salt - KDF(s0, hashLength, (unsigned char*)respMasterKey, strlen(respMasterKey)+1, KDFcontext, kdfSize, keyLen, srtpKeyR); - KDF(s0, hashLength, (unsigned char*)respMasterSalt, strlen(respMasterSalt)+1, KDFcontext, kdfSize, 112, srtpSaltR); + KDF(s0, hashLength, (unsigned char*)respMasterKey, (int32_t)strlen(respMasterKey)+1, KDFcontext, kdfSize, keyLen, srtpKeyR); + KDF(s0, hashLength, (unsigned char*)respMasterSalt, (int32_t)strlen(respMasterSalt)+1, KDFcontext, kdfSize, 112, srtpSaltR); // The HMAC keys for GoClear - KDF(s0, hashLength, (unsigned char*)iniHmacKey, strlen(iniHmacKey)+1, KDFcontext, kdfSize, hashLength*8, hmacKeyI); - KDF(s0, hashLength, (unsigned char*)respHmacKey, strlen(respHmacKey)+1, KDFcontext, kdfSize, hashLength*8, hmacKeyR); + KDF(s0, hashLength, (unsigned char*)iniHmacKey, (int32_t)strlen(iniHmacKey)+1, KDFcontext, kdfSize, hashLength*8, hmacKeyI); + KDF(s0, hashLength, (unsigned char*)respHmacKey, (int32_t)strlen(respHmacKey)+1, KDFcontext, kdfSize, hashLength*8, hmacKeyR); // The keys for Confirm messages - KDF(s0, hashLength, (unsigned char*)iniZrtpKey, strlen(iniZrtpKey)+1, KDFcontext, kdfSize, keyLen, zrtpKeyI); - KDF(s0, hashLength, (unsigned char*)respZrtpKey, strlen(respZrtpKey)+1, KDFcontext, kdfSize, keyLen, zrtpKeyR); + KDF(s0, hashLength, (unsigned char*)iniZrtpKey, (int32_t)strlen(iniZrtpKey)+1, KDFcontext, kdfSize, keyLen, zrtpKeyI); + KDF(s0, hashLength, (unsigned char*)respZrtpKey, (int32_t)strlen(respZrtpKey)+1, KDFcontext, kdfSize, keyLen, zrtpKeyR); detailInfo.pubKey = detailInfo.sasType = NULL; if (!multiStream) { // Compute the new Retained Secret - KDF(s0, hashLength, (unsigned char*)retainedSec, strlen(retainedSec)+1, KDFcontext, kdfSize, SHA256_DIGEST_LENGTH*8, newRs1); + KDF(s0, hashLength, (unsigned char*)retainedSec, (int32_t)strlen(retainedSec)+1, KDFcontext, kdfSize, SHA256_DIGEST_LENGTH*8, newRs1); // Compute the ZRTP Session Key - KDF(s0, hashLength, (unsigned char*)zrtpSessionKey, strlen(zrtpSessionKey)+1, KDFcontext, kdfSize, hashLength*8, zrtpSession); + KDF(s0, hashLength, (unsigned char*)zrtpSessionKey, (int32_t)strlen(zrtpSessionKey)+1, KDFcontext, kdfSize, hashLength*8, zrtpSession); // perform generation according to chapter 5.5 and 8. // we don't need a speciai sasValue filed. sasValue are the first // (leftmost) 32 bits (4 bytes) of sasHash uint8_t sasBytes[4]; - KDF(s0, hashLength, (unsigned char*)sasString, strlen(sasString)+1, KDFcontext, kdfSize, SHA256_DIGEST_LENGTH*8, sasHash); + KDF(s0, hashLength, (unsigned char*)sasString, (int32_t)strlen(sasString)+1, KDFcontext, kdfSize, SHA256_DIGEST_LENGTH*8, sasHash); // according to chapter 8 only the leftmost 20 bits of sasValue (aka // sasHash) are used to create the character SAS string of type SAS diff --git a/zrtp/ZrtpCWrapper.cpp b/zrtp/ZrtpCWrapper.cpp index d3eecdd0..6913318f 100644 --- a/zrtp/ZrtpCWrapper.cpp +++ b/zrtp/ZrtpCWrapper.cpp @@ -206,7 +206,7 @@ char* zrtp_getMultiStrParams(ZrtpContext* zrtpContext, int32_t *length) { if (ret.size() == 0) return NULL; - *length = ret.size(); + *length = (int32_t)ret.size(); char* retval = (char*) malloc(ret.size()); ret.copy(retval, ret.size(), 0); return retval; diff --git a/zrtp/ZrtpConfigure.cpp b/zrtp/ZrtpConfigure.cpp index 6a22983b..cec8dc01 100644 --- a/zrtp/ZrtpConfigure.cpp +++ b/zrtp/ZrtpConfigure.cpp @@ -91,7 +91,7 @@ void EnumBase::insert(const char* name, int32_t klen, const char* ra, } int EnumBase::getSize() { - return algos.size(); + return (int)algos.size(); } AlgoTypes EnumBase::getAlgoType() { diff --git a/zrtp/ZrtpSdesStream.cpp b/zrtp/ZrtpSdesStream.cpp index 2f1085cd..85312891 100644 --- a/zrtp/ZrtpSdesStream.cpp +++ b/zrtp/ZrtpSdesStream.cpp @@ -324,21 +324,21 @@ int ZrtpSdesStream::getCryptoMixAttribute(char *algoNames, size_t length) { for (cryptoMix* cp = knownMixAlgos; cp->name != NULL; cp++) { if (cp->hashLength == cryptoMixHashLength && cp->hashType == cryptoMixHashType) { strcpy(algoNames, cp->name); - return strlen(cp->name); + return (int)strlen(cp->name); } } } // TODO: enhance here to support multiple algorithms (concatenate strings into the buffer until buffer full) else { strcpy(algoNames, knownMixAlgos[0].name); - return strlen(algoNames); + return (int)strlen(algoNames); } return 0; } bool ZrtpSdesStream::setCryptoMixAttribute(const char *algoNames) { - int len = strlen(algoNames); + int len = (int)strlen(algoNames); if (len <= 0) return false; @@ -391,7 +391,7 @@ static int _random(unsigned char *output, size_t len) #include static int _random(unsigned char *output, size_t len) { - return ZrtpRandom::getRandomData(output, len); + return ZrtpRandom::getRandomData(output, (uint32_t)len); } #endif @@ -647,7 +647,7 @@ bool ZrtpSdesStream::createSdesProfile(char *cryptoString, size_t *maxLen) { localKeyLenBytes = pSuite->keyLength / 8; localSaltLenBytes = pSuite->saltLength / 8; - if (tag == -1) + if ((tag == -1) || (tag > maxTagValue)) tag = 1; // Get B64 code for master key and master salt and then construct the SDES crypto string diff --git a/zrtp/libzrtpcpp/Base32.h b/zrtp/libzrtpcpp/Base32.h index fbe29837..ff14d9d1 100644 --- a/zrtp/libzrtpcpp/Base32.h +++ b/zrtp/libzrtpcpp/Base32.h @@ -136,7 +136,7 @@ class Base32 { * The length of the base-32 encoding of the data in characters */ static size_t const b2alen(const size_t lengthInBits) { - return divceil(lengthInBits, 5); }; + return divceil((int)lengthInBits, 5); }; private: diff --git a/zrtp/libzrtpcpp/ZrtpCWrapper.h b/zrtp/libzrtpcpp/ZrtpCWrapper.h index 66038f02..d4f69946 100644 --- a/zrtp/libzrtpcpp/ZrtpCWrapper.h +++ b/zrtp/libzrtpcpp/ZrtpCWrapper.h @@ -974,7 +974,7 @@ extern "C" * if it does not use the string anymore. */ const char* zrtp_getSasType(ZrtpContext* zrtpContext); -#warning zrtp_getSasType(...) API changed - caller shall free() returned data +//#warning zrtp_getSasType(...) API changed - caller shall free() returned data /** * Get the computed SAS hash for this ZRTP session. diff --git a/zrtp/zrtpB64Decode.c b/zrtp/zrtpB64Decode.c index d0fb69e0..7b2e42e9 100644 --- a/zrtp/zrtpB64Decode.c +++ b/zrtp/zrtpB64Decode.c @@ -40,7 +40,7 @@ int base64_decode_block(const char* code_in, const int length_in, uint8_t *plain { state_in->step = step_a; state_in->plainchar = *plainchar; - return plainchar - plaintext_out; + return (int)(plainchar - plaintext_out); } fragment = (char)base64_decode_value(*codechar++); } while (fragment < 0); @@ -51,7 +51,7 @@ int base64_decode_block(const char* code_in, const int length_in, uint8_t *plain { state_in->step = step_b; state_in->plainchar = *plainchar; - return plainchar - plaintext_out; + return (int)(plainchar - plaintext_out); } fragment = (char)base64_decode_value(*codechar++); } while (fragment < 0); @@ -63,7 +63,7 @@ int base64_decode_block(const char* code_in, const int length_in, uint8_t *plain { state_in->step = step_c; state_in->plainchar = *plainchar; - return plainchar - plaintext_out; + return (int)(plainchar - plaintext_out); } fragment = (char)base64_decode_value(*codechar++); } while (fragment < 0); @@ -75,7 +75,7 @@ int base64_decode_block(const char* code_in, const int length_in, uint8_t *plain { state_in->step = step_d; state_in->plainchar = *plainchar; - return plainchar - plaintext_out; + return (int)(plainchar - plaintext_out); } fragment = (char)base64_decode_value(*codechar++); } while (fragment < 0); diff --git a/zrtp/zrtpB64Encode.c b/zrtp/zrtpB64Encode.c index 241e3c57..94be822c 100644 --- a/zrtp/zrtpB64Encode.c +++ b/zrtp/zrtpB64Encode.c @@ -46,7 +46,7 @@ int base64_encode_block(const uint8_t *plaintext_in, int length_in, char* code_o { state_in->result = result; state_in->step = step_A; - return codechar - code_out; + return (int)(codechar - code_out); } fragment = *plainchar++; result = (fragment & 0x0fc) >> 2; @@ -57,7 +57,7 @@ int base64_encode_block(const uint8_t *plaintext_in, int length_in, char* code_o { state_in->result = result; state_in->step = step_B; - return codechar - code_out; + return (int)(codechar - code_out); } fragment = *plainchar++; result |= (fragment & 0x0f0) >> 4; @@ -68,7 +68,7 @@ int base64_encode_block(const uint8_t *plaintext_in, int length_in, char* code_o { state_in->result = result; state_in->step = step_C; - return codechar - code_out; + return (int)(codechar - code_out); } fragment = *plainchar++; result |= (fragment & 0x0c0) >> 6; @@ -111,6 +111,6 @@ int base64_encode_blockend(char* code_out, base64_encodestate* state_in) if (state_in->lineLength > 0) *codechar++ = '\n'; - return codechar - code_out; + return (int)(codechar - code_out); } diff --git a/zrtp/zrtpCacheSqliteBackend.c b/zrtp/zrtpCacheSqliteBackend.c index a80843d0..52314af2 100644 --- a/zrtp/zrtpCacheSqliteBackend.c +++ b/zrtp/zrtpCacheSqliteBackend.c @@ -268,22 +268,22 @@ static int initializeRemoteTables(sqlite3 *db, char* errString) * deleted using DB admin command then we need to drop the remote id table * and names also to have a clean state. */ - rc = SQLITE_PREPARE(db, dropZrtpIdRemote, strlen(dropZrtpIdRemote)+1, &stmt, NULL); + rc = SQLITE_PREPARE(db, dropZrtpIdRemote, (int)strlen(dropZrtpIdRemote)+1, &stmt, NULL); rc = sqlite3_step(stmt); sqlite3_finalize(stmt); - rc = SQLITE_PREPARE(db, dropZrtpNames, strlen(dropZrtpNames)+1, &stmt, NULL); + rc = SQLITE_PREPARE(db, dropZrtpNames, (int)strlen(dropZrtpNames)+1, &stmt, NULL); rc = sqlite3_step(stmt); sqlite3_finalize(stmt); - SQLITE_CHK(SQLITE_PREPARE(db, createZrtpIdRemote, strlen(createZrtpIdRemote)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, createZrtpIdRemote, (int)strlen(createZrtpIdRemote)+1, &stmt, NULL)); rc = sqlite3_step(stmt); sqlite3_finalize(stmt); if (rc != SQLITE_DONE) { ERRMSG; return rc; } - SQLITE_CHK(SQLITE_PREPARE(db, createZrtpNames, strlen(createZrtpNames)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, createZrtpNames, (int)strlen(createZrtpNames)+1, &stmt, NULL)); rc = sqlite3_step(stmt); sqlite3_finalize(stmt); if (rc != SQLITE_DONE) { @@ -309,7 +309,7 @@ static int createTables(sqlite3 *db, char* errString) int rc; /* no ZRTP cache tables were found - create them, first the OwnId table */ - SQLITE_CHK(SQLITE_PREPARE(db, createZrtpIdOwn, strlen(createZrtpIdOwn)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, createZrtpIdOwn, (int)strlen(createZrtpIdOwn)+1, &stmt, NULL)); rc = sqlite3_step(stmt); sqlite3_finalize(stmt); @@ -340,11 +340,11 @@ static int insertRemoteZidRecord(void *vdb, const uint8_t *remoteZid, const uint /* Get B64 code for localZid now */ b64Encode(localZid, IDENTIFIER_LEN, b64LocalZid, IDENTIFIER_LEN*2); - SQLITE_CHK(SQLITE_PREPARE(db, insertZrtpIdRemote, strlen(insertZrtpIdRemote)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, insertZrtpIdRemote, (int)strlen(insertZrtpIdRemote)+1, &stmt, NULL)); /* For *_bind_* methods: column index starts with 1 (one), not zero */ - SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, strlen(b64RemoteZid), SQLITE_STATIC)); - SQLITE_CHK(sqlite3_bind_text(stmt, 12, b64LocalZid, strlen(b64LocalZid), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, (int)strlen(b64RemoteZid), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 12, b64LocalZid, (int)strlen(b64LocalZid), SQLITE_STATIC)); SQLITE_CHK(sqlite3_bind_int(stmt, 2, remZid->flags)); SQLITE_CHK(sqlite3_bind_blob(stmt, 3, remZid->rs1, RS_LENGTH, SQLITE_STATIC)); SQLITE_CHK(sqlite3_bind_int64(stmt, 4, remZid->rs1LastUse)); @@ -387,12 +387,12 @@ static int updateRemoteZidRecord(void *vdb, const uint8_t *remoteZid, const uint /* Get B64 code for localZid now */ b64Encode(localZid, IDENTIFIER_LEN, b64LocalZid, IDENTIFIER_LEN*2); - SQLITE_CHK(SQLITE_PREPARE(db, updateZrtpIdRemote, strlen(updateZrtpIdRemote)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, updateZrtpIdRemote, (int)strlen(updateZrtpIdRemote)+1, &stmt, NULL)); /* For *_bind_* methods: column index starts with 1 (one), not zero */ /* Select for update with the following keys */ - SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, strlen(b64RemoteZid), SQLITE_STATIC)); - SQLITE_CHK(sqlite3_bind_text(stmt, 12, b64LocalZid, strlen(b64LocalZid), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, (int)strlen(b64RemoteZid), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 12, b64LocalZid, (int)strlen(b64LocalZid), SQLITE_STATIC)); /* Update the following values */ SQLITE_CHK(sqlite3_bind_int(stmt, 2, remZid->flags)); @@ -437,9 +437,9 @@ static int readRemoteZidRecord(void *vdb, const uint8_t *remoteZid, const uint8_ /* Get B64 code for localZid */ b64Encode(localZid, IDENTIFIER_LEN, b64LocalZid, IDENTIFIER_LEN*2); - SQLITE_CHK(SQLITE_PREPARE(db, selectZrtpIdRemoteAll, strlen(selectZrtpIdRemoteAll)+1, &stmt, NULL)); - SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, strlen(b64RemoteZid), SQLITE_STATIC)); - SQLITE_CHK(sqlite3_bind_text(stmt, 2, b64LocalZid, strlen(b64LocalZid), SQLITE_STATIC)); + SQLITE_CHK(SQLITE_PREPARE(db, selectZrtpIdRemoteAll, (int)strlen(selectZrtpIdRemoteAll)+1, &stmt, NULL)); + SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, (int)strlen(b64RemoteZid), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 2, b64LocalZid, (int)strlen(b64LocalZid), SQLITE_STATIC)); /* Getting data from result set: column index starts with 0 (zero), not one */ while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) { @@ -493,16 +493,16 @@ static int readLocalZid(void *vdb, uint8_t *localZid, const char *accountInfo, c } /* Find a localZid record for this combination */ - SQLITE_CHK(SQLITE_PREPARE(db, selectZrtpIdOwn, strlen(selectZrtpIdOwn)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, selectZrtpIdOwn, (int)strlen(selectZrtpIdOwn)+1, &stmt, NULL)); SQLITE_CHK(sqlite3_bind_int(stmt, 1, type)); - SQLITE_CHK(sqlite3_bind_text(stmt, 2, accountInfo, strlen(accountInfo), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 2, accountInfo, (int)strlen(accountInfo), SQLITE_STATIC)); /* Loop over result set and count it. However, use only the localZid of first row */ while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) { if (found == 0) { zidBase64Text = (char *)sqlite3_column_text(stmt, 0); - b64Decode(zidBase64Text, strlen(zidBase64Text), localZid, IDENTIFIER_LEN); + b64Decode(zidBase64Text, (int)strlen(zidBase64Text), localZid, IDENTIFIER_LEN); } found++; } @@ -521,11 +521,11 @@ static int readLocalZid(void *vdb, uint8_t *localZid, const char *accountInfo, c randomZRTP(localZid, IDENTIFIER_LEN); b64len = b64Encode(localZid, IDENTIFIER_LEN, b64zid, IDENTIFIER_LEN+IDENTIFIER_LEN); - SQLITE_CHK(SQLITE_PREPARE(db, insertZrtpIdOwn, strlen(insertZrtpIdOwn)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, insertZrtpIdOwn, (int)strlen(insertZrtpIdOwn)+1, &stmt, NULL)); SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64zid, b64len, SQLITE_STATIC)); SQLITE_CHK(sqlite3_bind_int(stmt, 2, type)); - SQLITE_CHK(sqlite3_bind_text(stmt, 3, accountInfo, strlen(accountInfo), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 3, accountInfo, (int)strlen(accountInfo), SQLITE_STATIC)); rc = sqlite3_step(stmt); sqlite3_finalize(stmt); @@ -578,7 +578,7 @@ static int openCache(const char* name, void **vpdb, char *errString) } /* check if ZRTP cache tables are already available, look if zrtpIdOwn is available */ - SQLITE_CHK(SQLITE_PREPARE(db, lookupTables, strlen(lookupTables)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, lookupTables, (int)strlen(lookupTables)+1, &stmt, NULL)); rc = sqlite3_step(stmt); sqlite3_finalize(stmt); @@ -617,7 +617,7 @@ static int clearCache(void *vdb, char *errString) sqlite3_stmt * stmt; int rc; - rc = SQLITE_PREPARE(db, dropZrtpIdOwn, strlen(dropZrtpIdOwn)+1, &stmt, NULL); + rc = SQLITE_PREPARE(db, dropZrtpIdOwn, (int)strlen(dropZrtpIdOwn)+1, &stmt, NULL); rc = sqlite3_step(stmt); sqlite3_finalize(stmt); @@ -646,16 +646,16 @@ static int insertZidNameRecord(void *vdb, const uint8_t *remoteZid, const uint8_ /* Get B64 code for localZid */ b64Encode(localZid, IDENTIFIER_LEN, b64LocalZid, IDENTIFIER_LEN*2); - SQLITE_CHK(SQLITE_PREPARE(db, insertZrtpNames, strlen(insertZrtpNames)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, insertZrtpNames, (int)strlen(insertZrtpNames)+1, &stmt, NULL)); /* For *_bind_* methods: column index starts with 1 (one), not zero */ - SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, strlen(b64RemoteZid), SQLITE_STATIC)); - SQLITE_CHK(sqlite3_bind_text(stmt, 2, b64LocalZid, strlen(b64LocalZid), SQLITE_STATIC)); - SQLITE_CHK(sqlite3_bind_text(stmt, 3, accountInfo, strlen(accountInfo), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, (int)strlen(b64RemoteZid), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 2, b64LocalZid, (int)strlen(b64LocalZid), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 3, accountInfo, (int)strlen(accountInfo), SQLITE_STATIC)); SQLITE_CHK(sqlite3_bind_int(stmt, 4, zidName->flags)); SQLITE_CHK(sqlite3_bind_int64(stmt, 5, (int64_t)time(NULL))); if (zidName->name != NULL) { - SQLITE_CHK(sqlite3_bind_text(stmt, 6, zidName->name, strlen(zidName->name), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 6, zidName->name, (int)strlen(zidName->name), SQLITE_STATIC)); } else { SQLITE_CHK(sqlite3_bind_text(stmt, 6, "_NO_NAME_", 9, SQLITE_STATIC)); @@ -694,19 +694,19 @@ static int updateZidNameRecord(void *vdb, const uint8_t *remoteZid, const uint8_ /* Get B64 code for localZid */ b64Encode(localZid, IDENTIFIER_LEN, b64LocalZid, IDENTIFIER_LEN*2); - SQLITE_CHK(SQLITE_PREPARE(db, updateZrtpNames, strlen(updateZrtpNames)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, updateZrtpNames, (int)strlen(updateZrtpNames)+1, &stmt, NULL)); /* For *_bind_* methods: column index starts with 1 (one), not zero */ /* Select for update with the following values */ - SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, strlen(b64RemoteZid), SQLITE_STATIC)); - SQLITE_CHK(sqlite3_bind_text(stmt, 2, b64LocalZid, strlen(b64LocalZid), SQLITE_STATIC)); - SQLITE_CHK(sqlite3_bind_text(stmt, 3, accountInfo, strlen(accountInfo), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, (int)strlen(b64RemoteZid), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 2, b64LocalZid, (int)strlen(b64LocalZid), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 3, accountInfo, (int)strlen(accountInfo), SQLITE_STATIC)); /* Update the following vaulues */ SQLITE_CHK(sqlite3_bind_int(stmt, 4, zidName->flags)); SQLITE_CHK(sqlite3_bind_int64(stmt, 5, (int64_t)time(NULL))); if (zidName->name != NULL) { - SQLITE_CHK(sqlite3_bind_text(stmt, 6, zidName->name, strlen(zidName->name), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 6, zidName->name, (int)strlen(zidName->name), SQLITE_STATIC)); } else { SQLITE_CHK(sqlite3_bind_text(stmt, 6, "_NO_NAME_", 9, SQLITE_STATIC)); @@ -745,11 +745,11 @@ static int readZidNameRecord(void *vdb, const uint8_t *remoteZid, const uint8_t /* Get B64 code for localZid */ b64Encode(localZid, IDENTIFIER_LEN, b64LocalZid, IDENTIFIER_LEN*2); - SQLITE_CHK(SQLITE_PREPARE(db, selectZrtpNames, strlen(selectZrtpNames)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, selectZrtpNames, (int)strlen(selectZrtpNames)+1, &stmt, NULL)); - SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, strlen(b64RemoteZid), SQLITE_STATIC)); - SQLITE_CHK(sqlite3_bind_text(stmt, 2, b64LocalZid, strlen(b64LocalZid), SQLITE_STATIC)); - SQLITE_CHK(sqlite3_bind_text(stmt, 3, accountInfo, strlen(accountInfo), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 1, b64RemoteZid, (int)strlen(b64RemoteZid), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 2, b64LocalZid, (int)strlen(b64LocalZid), SQLITE_STATIC)); + SQLITE_CHK(sqlite3_bind_text(stmt, 3, accountInfo, (int)strlen(accountInfo), SQLITE_STATIC)); /* Getting data from result set: column index starts with 0 (zero), not one */ while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) { @@ -784,7 +784,7 @@ static void *prepareReadAllZid(void *vdb, char *errString) sqlite3_stmt *stmt; int rc; - SQLITE_CHK(SQLITE_PREPARE(db, selectZrtpIdRemoteAllNoCondition, strlen(selectZrtpIdRemoteAllNoCondition)+1, &stmt, NULL)); + SQLITE_CHK(SQLITE_PREPARE(db, selectZrtpIdRemoteAllNoCondition, (int)strlen(selectZrtpIdRemoteAllNoCondition)+1, &stmt, NULL)); return stmt; cleanup: @@ -817,7 +817,7 @@ static void *readNextZidRecord(void *vdb, void *vstmt, remoteZidRecord_t *remZid remZid->secureSince = sqlite3_column_int64(stmt, 9); remZid->preshCounter = sqlite3_column_int(stmt, 10); zidBase64Text = (char *)sqlite3_column_text(stmt, 11); - b64Decode(zidBase64Text, strlen(zidBase64Text), remZid->identifier, IDENTIFIER_LEN); + b64Decode(zidBase64Text, (int32_t)strlen(zidBase64Text), remZid->identifier, IDENTIFIER_LEN); return stmt; } sqlite3_finalize(stmt); From d9b369e79ecded990a7dcceacd2c292fff8d09c1 Mon Sep 17 00:00:00 2001 From: Paul Herzog Date: Thu, 23 Oct 2014 17:14:46 -0400 Subject: [PATCH 2/3] Use full algorithm header file for Apple builds with Xcode 6.1 --- zrtp/ZRtp.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zrtp/ZRtp.cpp b/zrtp/ZRtp.cpp index 15b5f4e9..cb7ef4dd 100755 --- a/zrtp/ZRtp.cpp +++ b/zrtp/ZRtp.cpp @@ -19,7 +19,12 @@ * Authors: Werner Dittmann */ #include + +#ifdef __APPLE__ +#include +#else #include +#endif #include #include From 3764138bc8f10547354850f770a7e06554dbc749 Mon Sep 17 00:00:00 2001 From: Paul Herzog Date: Fri, 24 Oct 2014 15:26:37 -0400 Subject: [PATCH 3/3] Support int64_t formatting with clang --- clients/tivi/CtZrtpStream.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/tivi/CtZrtpStream.cpp b/clients/tivi/CtZrtpStream.cpp index da94e6f1..8861657b 100644 --- a/clients/tivi/CtZrtpStream.cpp +++ b/clients/tivi/CtZrtpStream.cpp @@ -410,11 +410,11 @@ int CtZrtpStream::isSecure() { #if __WORDSIZE == 64 #define T_ZRTP_L(_K,_I) \ if(iLen+1 == sizeof(_K) && strncmp(key,_K, iLen) == 0){ \ - return snprintf(p, maxLen, "%ld", _I);} + return snprintf(p, maxLen, "%ld", (long)_I);} #else #define T_ZRTP_L(_K,_I) \ if(iLen+1 == sizeof(_K) && strncmp(key,_K, iLen) == 0){ \ - return snprintf(p, maxLen, "%lld", _I);} + return snprintf(p, maxLen, "%lld", (long long)_I);} #endif int CtZrtpStream::getInfo(const char *key, char *p, int maxLen) {