From 36623f0869f7e1cae87ed163a8b0f2db27812d0e Mon Sep 17 00:00:00 2001 From: John Bland Date: Tue, 26 Sep 2023 20:41:33 -0400 Subject: [PATCH] fix ech config parsing to handle 1 byte public name len --- src/ssl.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 16be5dda7..8eaa1919a 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -652,7 +652,7 @@ int wolfSSL_SetEchConfigsBase64(WOLFSSL* ssl, char* echConfigs64, /* set the ech config from a raw buffer, this is the format ech configs are * sent using retry_configs from the ech server */ int wolfSSL_SetEchConfigs(WOLFSSL* ssl, const byte* echConfigs, - word32 echConfigsLen) + word32 echConfigsLen) { int ret = 0; int i; @@ -779,16 +779,17 @@ int wolfSSL_SetEchConfigs(WOLFSSL* ssl, const byte* echConfigs, &workingConfig->cipherSuites[j].aeadId); } echConfig += cipherSuitesLen; + /* ignore the maximum name length */ + echConfig++; /* publicNameLen */ - ato16(echConfig, &publicNameLen); + publicNameLen = *(echConfig); workingConfig->publicName = (char*)XMALLOC(publicNameLen + 1, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER); if (workingConfig->publicName == NULL) { ret = MEMORY_E; break; } - - echConfig += 2; + echConfig++; /* publicName */ XMEMCPY(workingConfig->publicName, echConfig, publicNameLen); /* null terminated */ @@ -965,9 +966,13 @@ int GetEchConfig(WOLFSSL_EchConfig* config, byte* output, word32* outputLen) output += 2; } + /* set maximum name length to 0 */ + *output = 0; + output++; + /* publicName len */ - c16toa(XSTRLEN(config->publicName), output); - output += 2; + *output = XSTRLEN(config->publicName); + output++; /* publicName */ XMEMCPY(output, config->publicName,