From 96c89383f0fe714889ab0b2a64c9a702030cfabd Mon Sep 17 00:00:00 2001 From: "[anp/hsw]" Date: Sat, 17 Aug 2024 21:10:14 +0700 Subject: [PATCH] proper fix for TLSExtractHostFromExt --- nfq/protocol.c | 4 ++-- tpws/protocol.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nfq/protocol.c b/nfq/protocol.c index a211963..8c19f62 100644 --- a/nfq/protocol.c +++ b/nfq/protocol.c @@ -277,11 +277,11 @@ static bool TLSExtractHostFromExt(const uint8_t *ext, size_t elen, char *host, s // u16 data+0 - name list length // u8 data+2 - server name type. 0=host_name // 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); ext += 5; elen -= 5; if (slen < elen) return false; - if (ext && len_host) + if (host && len_host) { if (slen >= len_host) slen = len_host - 1; for (size_t i = 0; i < slen; i++) host[i] = tolower(ext[i]); diff --git a/tpws/protocol.c b/tpws/protocol.c index 7d3fb1c..1facc59 100644 --- a/tpws/protocol.c +++ b/tpws/protocol.c @@ -267,11 +267,11 @@ static bool TLSExtractHostFromExt(const uint8_t *ext, size_t elen, char *host, s // u16 data+0 - name list length // u8 data+2 - server name type. 0=host_name // 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); ext += 5; elen -= 5; if (slen < elen) return false; - if (ext && len_host) + if (host && len_host) { if (slen >= len_host) slen = len_host - 1; for (size_t i = 0; i < slen; i++) host[i] = tolower(ext[i]);