Commit 91330b49 authored by Ben Sartor's avatar Ben Sartor Committed by johan

selectCommonAlgo now makes sure to not return an array with more than 7 elements

Signed-off-by: johan's avatarJohan Pascal <johan.pascal@belledonne-communications.com>
parent b72daee4
......@@ -131,9 +131,9 @@ int updateCryptoFunctionPointers(bzrtpChannelContext_t *zrtpChannelContext);
* @param[in] masterArrayLength Number of valids element in the master array
* @param[in] slaveArray The available algo, order is not taken in account
* @param[in] slaveArrayLength Number of valids element in the slave array
* @param[out] commonArray The available algo, order is not taken in account
* @param[out] commonArray Common algorithms found, max size 7
*
* @return the number of common algorithm found
* @return the number of common algorithms found
*/
uint8_t selectCommonAlgo(uint8_t masterArray[7], uint8_t masterArrayLength, uint8_t slaveArray[7], uint8_t slaveArrayLength, uint8_t commonArray[7]);
......
......@@ -819,7 +819,6 @@ void bzrtp_setSupportedCryptoTypes(bzrtpContext_t *zrtpContext, uint8_t algoType
return;
}
supportedTypesCount = supportedTypesCount < 7 ? supportedTypesCount : 7;
implementedTypesCount = bzrtpCrypto_getAvailableCryptoTypes(algoType, implementedTypes);
switch(algoType) {
......
......@@ -433,9 +433,9 @@ int updateCryptoFunctionPointers(bzrtpChannelContext_t *zrtpChannelContext) {
* @param[in] masterArrayLength Number of valids element in the master array
* @param[in] slaveArray The available algo, order is not taken in account
* @param[in] slaveArrayLength Number of valids element in the slave array
* @param[out] commonArray The available algo, order is not taken in account
* @param[out] commonArray Common algorithms found, max size 7
*
* @return the number of common algorithm found
* @return the number of common algorithms found
*/
uint8_t selectCommonAlgo(uint8_t masterArray[7], uint8_t masterArrayLength, uint8_t slaveArray[7], uint8_t slaveArrayLength, uint8_t commonArray[7]) {
int i,j;
......@@ -445,6 +445,10 @@ uint8_t selectCommonAlgo(uint8_t masterArray[7], uint8_t masterArrayLength, uint
if (masterArray[i] == slaveArray[j]) { /* found one, insert it in the common array */
commonArray[commonLength] = masterArray[i];
commonLength++;
if (commonLength == 7) {
return commonLength;
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment