From 54d5afae49191992ef0f346a9d2deab93fddb271 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 27 Jun 2019 19:31:50 -0700 Subject: [PATCH] ircd::m::id: Fix id::event::v3/v4 hashing ctor return view of sigil. --- ircd/m_id.cc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ircd/m_id.cc b/ircd/m_id.cc index c197db127..041bd7344 100644 --- a/ircd/m_id.cc +++ b/ircd/m_id.cc @@ -707,7 +707,15 @@ ircd::m::id::event::v3::v3(const mutable_buffer &out, }; out[0] = '$'; - return b64encode_unpadded(out + 1, hash); + const string_view hashb64 + { + b64encode_unpadded(out + 1, hash) + }; + + return string_view + { + ircd::data(out), 1 + ircd::size(hashb64) + }; }()} { } @@ -742,10 +750,13 @@ ircd::m::id::event::v4::v4(const mutable_buffer &out, }; out[0] = '$'; - string_view ret; - ret = b64encode_unpadded(out + 1, hash); - ret = b64tob64url(out + 1, ret); - return ret; + string_view hashb64; + hashb64 = b64encode_unpadded(out + 1, hash); + hashb64 = b64tob64url(out + 1, hashb64); + return string_view + { + ircd::data(out), 1 + ircd::size(hashb64) + }; }()} { }