From: Otto Moerbeek Date: Thu, 23 Jun 2022 14:23:05 +0000 (+0200) Subject: Fix a few warnings found by compiler on MacOS, where char is unsigned X-Git-Tag: auth-4.8.0-alpha0~38^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=abb8aeb0b8d0a496aa6e7653db8fc80d89dda4e1;p=thirdparty%2Fpdns.git Fix a few warnings found by compiler on MacOS, where char is unsigned --- diff --git a/pdns/dnslabeltext.rl b/pdns/dnslabeltext.rl index 87a5799672..27f435094d 100644 --- a/pdns/dnslabeltext.rl +++ b/pdns/dnslabeltext.rl @@ -108,11 +108,11 @@ DNSName::string_t segmentDNSNameRaw(const char* realinput, size_t inputlen) const char* eof = pe; int cs; char val = 0; - char labellen=0; + unsigned char labellen=0; unsigned int lenpos=0; %%{ action labelEnd { - if (labellen < 0 || labellen > 63) { + if (labellen > 63) { throw runtime_error("Unable to parse DNS name '"+string(realinput)+"': invalid label length "+std::to_string(labellen)); } ret[lenpos]=labellen; diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index c2b48e9fd7..22e2cf9f57 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -255,8 +255,8 @@ bool DNSName::isPartOf(const DNSName& parent) const } return true; } - if (*us < 0) { - throw std::out_of_range("negative label length in dnsname"); + if (static_cast(*us) > 63) { + throw std::out_of_range("illegal label length in dnsname"); } } return false;