]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#851,!24-p] Make sure we're not trying to dereference after vector end
authorTomek Mrugalski <tomasz@isc.org>
Fri, 23 Aug 2019 12:25:47 +0000 (14:25 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Fri, 23 Aug 2019 12:25:47 +0000 (14:25 +0200)
src/lib/cryptolink/botan_hash.cc
src/lib/cryptolink/botan_hmac.cc

index 8a1e37bb4f1887f5159bc6aa50b2716211a3afa5..cd21e148bbd4ff793bc7867e41e16cc3602c1f3b 100644 (file)
@@ -142,7 +142,10 @@ public:
             if (len > b_result.size()) {
                 len = b_result.size();
             }
-            return (std::vector<uint8_t>(&b_result[0], &b_result[len]));
+            // Return vector with content. Construct &b_result[len] attempts
+            // to get an address of one element beyond the b_result. Replaced
+            // with the address of first element + len
+            return (std::vector<uint8_t>(&b_result[0], &b_result[0]+len));
         } catch (const Botan::Exception& exc) {
             isc_throw(isc::cryptolink::LibraryError,
                       "Botan error: " << exc.what());
index c7175d6b94d353c9cbb5c2a8923e415ea11d352b..95fb50050fcdbf3576eb1853dfcd304bf74cbdc1 100644 (file)
@@ -149,7 +149,10 @@ public:
             if (len > b_result.size()) {
                 len = b_result.size();
             }
-            return (std::vector<uint8_t>(&b_result[0], &b_result[len]));
+            // Return vector with content. Construct &b_result[len] attempts
+            // to get an address of one element beyond the b_result. Replaced
+            // with the address of first element + len
+            return (std::vector<uint8_t>(&b_result[0], &b_result[0]+len));
         } catch (const Botan::Exception& exc) {
             isc_throw(LibraryError, "Botan error: " << exc.what());
         }