From: Remi Gacogne Date: Mon, 20 Sep 2021 07:46:49 +0000 (+0200) Subject: Credentials: Fix a possible overflow with a very large work factor X-Git-Tag: dnsdist-1.7.0-alpha1~7^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ef92c6c09fabe69eb99b0bc3aea8aba3db27faf;p=thirdparty%2Fpdns.git Credentials: Fix a possible overflow with a very large work factor Reported by Coverity as CID 1462395. --- diff --git a/pdns/credentials.cc b/pdns/credentials.cc index 2cefba2a17..f2f882db2c 100644 --- a/pdns/credentials.cc +++ b/pdns/credentials.cc @@ -234,7 +234,7 @@ static void parseHashed(const std::string& hash, std::string& salt, std::string& try { workFactor = pdns_stou(parameters.at(0).substr(3)); - workFactor = 1 << workFactor; + workFactor = static_cast(1) << workFactor; if (workFactor > pwhash_max_work_factor) { throw std::runtime_error("Invalid work factor of " + std::to_string(workFactor) + " in hashed password string, maximum is " + std::to_string(pwhash_max_work_factor)); }