Reject an over-long or empty object_storage key

key_type stores a key of key_size or longer as the empty key.
This commit is contained in:
noctuum
2026-09-18 14:56:13 +05:00
committed by Jari Sundell
parent bd00b5f6fe
commit b1be898ba1
2 changed files with 17 additions and 2 deletions
+6 -2
View File
@@ -64,8 +64,12 @@ object_storage::insert(const char* key_data, uint32_t key_size, const torrent::O
if (std::find(key_data, key_data + key_size, '\0') != key_data + key_size)
throw torrent::input_error("Found nul-char in string.");
// Check for size > key_size.
// Check for empty string.
// key_type turns a key this long into the empty key.
if (key_size >= object_storage::key_size)
throw torrent::input_error("Key is too long.");
if (key_size == 0)
throw torrent::input_error("Key is empty.");
bool use_raw = false;
torrent::Object object;