proper fix for TLSExtractHostFromExt

This commit is contained in:
[anp/hsw] 2024-08-17 21:10:14 +07:00
parent e8a940148a
commit 96c89383f0
2 changed files with 4 additions and 4 deletions

View File

@ -277,11 +277,11 @@ static bool TLSExtractHostFromExt(const uint8_t *ext, size_t elen, char *host, s
// u16 data+0 - name list length // u16 data+0 - name list length
// u8 data+2 - server name type. 0=host_name // u8 data+2 - server name type. 0=host_name
// u16 data+3 - server name length // u16 data+3 - server name length
if (elen < 5 || (ext && ext[2] != 0)) return false; if (elen < 5 || ext[2] != 0) return false;
size_t slen = pntoh16(ext + 3); size_t slen = pntoh16(ext + 3);
ext += 5; elen -= 5; ext += 5; elen -= 5;
if (slen < elen) return false; if (slen < elen) return false;
if (ext && len_host) if (host && len_host)
{ {
if (slen >= len_host) slen = len_host - 1; if (slen >= len_host) slen = len_host - 1;
for (size_t i = 0; i < slen; i++) host[i] = tolower(ext[i]); for (size_t i = 0; i < slen; i++) host[i] = tolower(ext[i]);

View File

@ -267,11 +267,11 @@ static bool TLSExtractHostFromExt(const uint8_t *ext, size_t elen, char *host, s
// u16 data+0 - name list length // u16 data+0 - name list length
// u8 data+2 - server name type. 0=host_name // u8 data+2 - server name type. 0=host_name
// u16 data+3 - server name length // u16 data+3 - server name length
if (elen < 5 || (ext && ext[2] != 0)) return false; if (elen < 5 || ext[2] != 0) return false;
size_t slen = pntoh16(ext + 3); size_t slen = pntoh16(ext + 3);
ext += 5; elen -= 5; ext += 5; elen -= 5;
if (slen < elen) return false; if (slen < elen) return false;
if (ext && len_host) if (host && len_host)
{ {
if (slen >= len_host) slen = len_host - 1; if (slen >= len_host) slen = len_host - 1;
for (size_t i = 0; i < slen; i++) host[i] = tolower(ext[i]); for (size_t i = 0; i < slen; i++) host[i] = tolower(ext[i]);