From 00f3ea6691d3b5eeacf6e8cfb1922a4b36100a66 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 18 Sep 2026 15:40:48 -0400 Subject: [PATCH] check for terminating 'e' for BEncoded disctonaries and lists --- libi2pd_client/Torrents.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libi2pd_client/Torrents.cpp b/libi2pd_client/Torrents.cpp index 0e293d7d..e640c4b4 100644 --- a/libi2pd_client/Torrents.cpp +++ b/libi2pd_client/Torrents.cpp @@ -84,7 +84,8 @@ namespace torrents len += offset; buf = buf.substr (offset); } - if (buf[0] == 'e') len++; + if (buf.empty ()) return 0; // maformed dictionary without terminating 'e' + len++; // 'e' return len; } @@ -104,7 +105,8 @@ namespace torrents len += l; buf = buf.substr (l); } - if (buf[0] == 'e') len++; + if (buf.empty ()) return 0; // maformed list without terminating 'e' + len++; // 'e' return len; }