Fix core subsystem logic and safety bugs @Sirus20x6

This commit is contained in:
Jari Sundell
2026-04-17 18:54:46 +02:00
committed by GitHub
parent 4235507292
commit 1adcf230d2
10 changed files with 43 additions and 23 deletions
+4
View File
@@ -1,6 +1,7 @@
#include "config.h"
#include <algorithm>
#include <cstring>
#include <fstream>
#include <iostream>
#include <torrent/data/file.h>
@@ -82,6 +83,9 @@ DownloadList::find(const torrent::HashString& hash) {
DownloadList::iterator
DownloadList::find_hex(const char* hash) {
if (strlen(hash) < 40)
return end();
torrent::HashString key;
if (torrent::utils::transform_from_hex(hash, hash + 40, key) != key.end())
+3 -2
View File
@@ -238,9 +238,10 @@ is_data_uri(const std::string& uri) {
std::string
decode_data_uri(const std::string& uri) {
const auto start = uri.find("base64,", 5) + 7;
if (start == std::string::npos)
const auto pos = uri.find("base64,", 5);
if (pos == std::string::npos)
throw torrent::input_error("Invalid data uri: not base64 encoded.");
const auto start = pos + 7;
if (start >= uri.size())
throw torrent::input_error("Empty base64.");
return utils::decode_base64(uri.substr(start));