From da4ad592905bc59dc572c2221ba563a238fbfe7a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 21 Jan 2022 17:17:49 -0600 Subject: [PATCH] fix: in check input before calling tr_sha1_from_string() (#2468) Fixes #2467 --- libtransmission/session.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libtransmission/session.cc b/libtransmission/session.cc index 495c88fac..b99ff47a4 100644 --- a/libtransmission/session.cc +++ b/libtransmission/session.cc @@ -2833,6 +2833,7 @@ void tr_sessionRemoveTorrent(tr_session* session, tr_torrent* tor) tr_torrent* tr_session::getTorrent(std::string_view info_dict_hash_string) { - auto info_dict_hash = tr_sha1_from_string(std::data(info_dict_hash_string)); - return this->getTorrent(info_dict_hash); + return std::size(info_dict_hash_string) == TR_SHA1_DIGEST_STRLEN ? + this->getTorrent(tr_sha1_from_string(info_dict_hash_string)) : + nullptr; }