Skip to contentSkip to conversation

Fix off-by-one in tls-crypt-v2 client wrapping with custom metadata

PATCH In review Arne Schwabe 2 participants 2 messages Apr 3, 2020 – Apr 6, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix off-by-one in tls-crypt-v2 client wrapping with custom metadata

Instead of writing at the end of the metadata buffer, the decoded base64 data overwrites the opcode as BPTR points to the beginning of the buffer and not the current position. Replace with BEND to fix this off-by-one

---
 src/openvpn/tls_crypt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/tls_crypt.c +1 -1
index 37df2ce7..e9f9cc2a 100644
@@ -664,7 +664,7 @@ tls_crypt_v2_write_client_key_file(const char *filename,
                 (int)strlen(b64_metadata), TLS_CRYPT_V2_MAX_B64_METADATA_LEN);
         }
         ASSERT(buf_write(&metadata, &TLS_CRYPT_METADATA_TYPE_USER, 1));
-        int decoded_len = openvpn_base64_decode(b64_metadata, BPTR(&metadata),
+        int decoded_len = openvpn_base64_decode(b64_metadata, BEND(&metadata),
                                                 BCAP(&metadata));
         if (decoded_len < 0)
         {
Signature · 1 line
2.26.0
#1 lore raw

Your patch has been applied to the master branch.

While a bugfix, the code in question is not in release/2.4, so no need to backport.

No real testing done, just a quick test compile.

commit e23fb6b8c88a2aec160965769f6467d455c0d010 (master)

Author: Arne Schwabe
Date:   Fri Apr 3 11:09:44 2020 +0200
     Fix off-by-one in tls-crypt-v2 client wrapping with custom metadata

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Steffan Karger <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg19695.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering