X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=inline;f=include%2Fconvto.h;h=9bad62b93d0894782aaa02a649c020a9e234173c;hb=ad1ad11067ab089710305c030b00e966f3f10d17;hp=2f808d1fb3a722128a8047f8e6ca1973016a8fcf;hpb=87b1461e2a4710a38b32186c2582da9fe9bb3804;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/convto.h b/include/convto.h index 2f808d1fb..9bad62b93 100644 --- a/include/convto.h +++ b/include/convto.h @@ -1,8 +1,9 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2014 Attila Molnar - * Copyright (C) 2006 Craig Edwards + * Copyright (C) 2020 Matt Schatz + * Copyright (C) 2017-2019 Sadie Powell + * Copyright (C) 2016 Attila Molnar * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -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; }