X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fconvto.h;h=9bad62b93d0894782aaa02a649c020a9e234173c;hb=a30a0074edac353cb60e134b43fa8ff0ffb67f8b;hp=9ace832612f292cd2bba47fd66f99ca00ceb5c21;hpb=aa692dc1039b63deef7886e914ec499abe7facaf;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/convto.h b/include/convto.h index 9ace83261..9bad62b93 100644 --- a/include/convto.h +++ b/include/convto.h @@ -1,6 +1,7 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2020 Matt Schatz * Copyright (C) 2017-2019 Sadie Powell * Copyright (C) 2016 Attila Molnar * @@ -104,14 +105,14 @@ template<> inline char ConvToNum(const std::string& in) { // We specialise ConvToNum for char to avoid istringstream treating // the input as a character literal. - uint16_t num = ConvToNum(in); - return num <= UINT8_MAX ? num : 0; + int16_t num = ConvToNum(in); + return num >= INT8_MIN && num <= INT8_MAX ? num : 0; } template<> inline unsigned char ConvToNum(const std::string& in) { // We specialise ConvToNum for unsigned char to avoid istringstream // treating the input as a character literal. - int16_t num = ConvToNum(in); - return num >= INT8_MIN && num <= INT8_MAX ? num : 0; + uint16_t num = ConvToNum(in); + return num <= UINT8_MAX ? num : 0; }