<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Fix invalid std::vector access (visible with tests on hardened systems)

From: Mattias Ellert &lt;mattias.ellert@physics.uu.se&gt;
Bug: https://github.com/scitokens/scitokens-cpp/pull/126
Bug: https://bugs.gentoo.org/922679

---
 src/scitokens_internal.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/src/scitokens_internal.cpp
+++ b/src/scitokens_internal.cpp
@@ -978,9 +978,9 @@ bool scitokens::Validator::store_public_ec_key(const std::string &amp;issuer,
     auto x_num = BN_num_bytes(x_bignum.get());
     auto y_num = BN_num_bytes(y_bignum.get());
     std::vector&lt;unsigned char&gt; x_bin;
-    x_bin.reserve(x_num);
+    x_bin.resize(x_num);
     std::vector&lt;unsigned char&gt; y_bin;
-    y_bin.reserve(y_num);
+    y_bin.resize(y_num);
     BN_bn2bin(x_bignum.get(), &amp;x_bin[0]);
     BN_bn2bin(y_bignum.get(), &amp;y_bin[0]);
     std::string x_str(reinterpret_cast&lt;char *&gt;(&amp;x_bin[0]), x_num);
</pre></body></html>