Merge pull request #2620 from tmael/ALPN_input

Fix alpn buffer overrun
This commit is contained in:
toddouska
2019-11-26 15:31:56 -08:00
committed by GitHub

View File

@@ -2409,7 +2409,7 @@ WOLFSSL_ABI
int wolfSSL_UseALPN(WOLFSSL* ssl, char *protocol_name_list,
word32 protocol_name_listSz, byte options)
{
char *list, *ptr, *token[10];
char *list, *ptr, *token[WOLFSSL_MAX_ALPN_NUMBER]={NULL};
word16 len;
int idx = 0;
int ret = WOLFSSL_FAILURE;
@@ -2445,7 +2445,7 @@ int wolfSSL_UseALPN(WOLFSSL* ssl, char *protocol_name_list,
/* read all protocol name from the list */
token[idx] = XSTRTOK(list, ",", &ptr);
while (token[idx] != NULL)
while (token[idx] != NULL && idx < WOLFSSL_MAX_ALPN_NUMBER)
token[++idx] = XSTRTOK(NULL, ",", &ptr);
/* add protocol name list in the TLS extension in reverse order */