]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Credentials: Fix a possible overflow with a very large work factor
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 20 Sep 2021 07:46:49 +0000 (09:46 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 20 Sep 2021 09:43:01 +0000 (11:43 +0200)
Reported by Coverity as CID 1462395.

pdns/credentials.cc

index 2cefba2a17e342206458d6aafb3ac55d8d49e296..f2f882db2c054adada5cbeb68f97e6a5155dc498 100644 (file)
@@ -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<uint64_t>(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));
     }