From: Tomek Mrugalski Date: Fri, 23 Aug 2019 12:25:47 +0000 (+0200) Subject: [#851,!24-p] Make sure we're not trying to dereference after vector end X-Git-Tag: Kea-1.6.0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2002087794ef9dcec8af2ea03dcfc0be15bd0c69;p=thirdparty%2Fkea.git [#851,!24-p] Make sure we're not trying to dereference after vector end --- diff --git a/src/lib/cryptolink/botan_hash.cc b/src/lib/cryptolink/botan_hash.cc index 8a1e37bb4f..cd21e148bb 100644 --- a/src/lib/cryptolink/botan_hash.cc +++ b/src/lib/cryptolink/botan_hash.cc @@ -142,7 +142,10 @@ public: if (len > b_result.size()) { len = b_result.size(); } - return (std::vector(&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(&b_result[0], &b_result[0]+len)); } catch (const Botan::Exception& exc) { isc_throw(isc::cryptolink::LibraryError, "Botan error: " << exc.what()); diff --git a/src/lib/cryptolink/botan_hmac.cc b/src/lib/cryptolink/botan_hmac.cc index c7175d6b94..95fb50050f 100644 --- a/src/lib/cryptolink/botan_hmac.cc +++ b/src/lib/cryptolink/botan_hmac.cc @@ -149,7 +149,10 @@ public: if (len > b_result.size()) { len = b_result.size(); } - return (std::vector(&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(&b_result[0], &b_result[0]+len)); } catch (const Botan::Exception& exc) { isc_throw(LibraryError, "Botan error: " << exc.what()); }