From 0ef92c6c09fabe69eb99b0bc3aea8aba3db27faf Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 20 Sep 2021 09:46:49 +0200 Subject: [PATCH] Credentials: Fix a possible overflow with a very large work factor Reported by Coverity as CID 1462395. --- pdns/credentials.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)); } -- 2.47.2