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;
}
return true;
}
- if (*us < 0) {
- throw std::out_of_range("negative label length in dnsname");
+ if (static_cast<uint8_t>(*us) > 63) {
+ throw std::out_of_range("illegal label length in dnsname");
}
}
return false;