]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
libssl: Fix the position of OCSP files on errors
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 18 May 2026 10:57:25 +0000 (12:57 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 18 May 2026 10:57:25 +0000 (12:57 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/libssl.cc

index f8c6e2e6363d668bc2804480b6230434da83883c..f9b70a40abdca809b595a58a4d7be30ef9ad00a1 100644 (file)
@@ -452,29 +452,29 @@ static std::map<int, std::string> libssl_load_ocsp_responses(const std::vector<s
 
   size_t count = 0;
   for (const auto& filename : ocspFiles) {
+    const size_t idx = count++;
     std::ifstream file(filename, std::ios::binary);
     std::string content;
     while (file) {
-      char buffer[4096];
-      file.read(buffer, sizeof(buffer));
+      std::array<char, 4096> buffer{};
+      file.read(buffer.data(), buffer.size());
       if (file.bad()) {
         file.close();
         warnings.push_back("Unable to load OCSP response from " + filename);
         continue;
       }
-      content.append(buffer, file.gcount());
+      content.append(buffer.data(), file.gcount());
     }
     file.close();
 
     try {
       libssl_validate_ocsp_response(content);
-      ocspResponses.insert({keyTypes.at(count), std::move(content)});
+      ocspResponses.insert({keyTypes.at(idx), std::move(content)});
     }
     catch (const std::exception& e) {
       warnings.push_back("Error checking the validity of OCSP response from '" + filename + "': " + e.what());
       continue;
     }
-    ++count;
   }
 
   return ocspResponses;