Merge pull request #2576 from pobregat0/sam-version-overflow

don't overflow int when parsing SAM version
This commit is contained in:
orignal authored and GitHub committed 2026-09-26 07:20:23 -04:00
commit ed9135be69
2 files changed
+2

No files matched your search

+1
View File
@@ -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');
}
+1
View File
@@ -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