forked from wolfSSL/wolfssl
fix on TLSX_SNI_GetFromBuffer - set inOutSz value to zero when there is no SNI extension in the client hello buffer.
This commit is contained in:
@@ -1047,6 +1047,8 @@ int TLSX_SNI_GetFromBuffer(const byte* clientHello, word32 helloSz,
|
|||||||
len16 -= min(2 * OPAQUE16_LEN + extLen, len16);
|
len16 -= min(2 * OPAQUE16_LEN + extLen, len16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*inOutSz = 0;
|
||||||
|
|
||||||
return len16 ? BUFFER_ERROR : SSL_SUCCESS;
|
return len16 ? BUFFER_ERROR : SSL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
tests/api.c
14
tests/api.c
@@ -390,9 +390,15 @@ static void test_CyaSSL_SNI_GetFromBuffer(void)
|
|||||||
|
|
||||||
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer3, sizeof(buffer3),
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer3, sizeof(buffer3),
|
||||||
0, result, &length));
|
0, result, &length));
|
||||||
|
AssertIntEQ(XSTRLEN(""), length);
|
||||||
|
|
||||||
|
length = 32;
|
||||||
|
|
||||||
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2),
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2),
|
||||||
1, result, &length));
|
1, result, &length));
|
||||||
|
AssertIntEQ(XSTRLEN(""), length);
|
||||||
|
|
||||||
|
length = 32;
|
||||||
|
|
||||||
AssertIntEQ(-228, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer), 0,
|
AssertIntEQ(-228, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer), 0,
|
||||||
result, &length));
|
result, &length));
|
||||||
@@ -410,15 +416,15 @@ static void test_CyaSSL_SNI_GetFromBuffer(void)
|
|||||||
result, &length));
|
result, &length));
|
||||||
buffer[4] = 0x64;
|
buffer[4] = 0x64;
|
||||||
|
|
||||||
AssertIntEQ(1, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer), 0,
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer, sizeof(buffer),
|
||||||
result, &length));
|
0, result, &length));
|
||||||
result[length] = 0;
|
result[length] = 0;
|
||||||
AssertStrEQ("www.paypal.com", (const char*) result);
|
AssertStrEQ("www.paypal.com", (const char*) result);
|
||||||
|
|
||||||
length = 32;
|
length = 32;
|
||||||
|
|
||||||
AssertIntEQ(1, CyaSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2), 0,
|
AssertIntEQ(SSL_SUCCESS, CyaSSL_SNI_GetFromBuffer(buffer2, sizeof(buffer2),
|
||||||
result, &length));
|
0, result, &length));
|
||||||
result[length] = 0;
|
result[length] = 0;
|
||||||
AssertStrEQ("api.textmate.org", (const char*) result);
|
AssertStrEQ("api.textmate.org", (const char*) result);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user