mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-22 19:41:41 +00:00
Merge pull request #2576 from pobregat0/sam-version-overflow
don't overflow int when parsing SAM version
This commit is contained in:
2 files changed
+2
No files matched your search
@@ -92,6 +92,7 @@ namespace client
|
||||
{
|
||||
if (ch >= '0' && ch <= '9')
|
||||
{
|
||||
if (version > MAX_SAM_VERSION_VALUE) continue; // don't overflow on a long number
|
||||
version *= 10;
|
||||
version += (ch - '0');
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ namespace client
|
||||
const char SAM_PONG[] = "PONG %s\n";
|
||||
|
||||
constexpr int MAKE_SAM_VERSION_NUMBER (int major, int minor) { return major*10 + minor; }
|
||||
constexpr int MAX_SAM_VERSION_VALUE = 99999; // stop parsing digits above that, any such version is out of range anyway
|
||||
constexpr int MIN_SAM_VERSION = MAKE_SAM_VERSION_NUMBER (3, 0);
|
||||
constexpr int MAX_SAM_VERSION = MAKE_SAM_VERSION_NUMBER (3, 3);
|
||||
constexpr int SAM_VERSION_33 = MAKE_SAM_VERSION_NUMBER (3, 3); // SAM 3.3
|
||||
|
||||
Reference in new issue
Block a user