From c1ce2febf06684f96f3452b541a2bf8a0aef79fc Mon Sep 17 00:00:00 2001 From: noctuum <25441068+noctuum@users.noreply.github.com> Date: Wed, 16 Sep 2026 17:31:22 +0500 Subject: [PATCH] Reject an over-long line instead of truncating getline sets failbit, which both loops read as end of input. --- src/command_ip.cc | 5 +++++ src/rpc/parse_commands.cc | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/command_ip.cc b/src/command_ip.cc index 6988a37c..1089589c 100644 --- a/src/command_ip.cc +++ b/src/command_ip.cc @@ -319,6 +319,11 @@ apply_ipv4_filter_load(const torrent::Object::list_type& args) { ipv4_filter_parse(buffer, value); } + if (file.fail() && !file.eof()) { + lineNumber++; + throw torrent::input_error("Exceeded max line length."); + } + } catch (torrent::input_error& e) { snprintf(buffer, 2048, "Error in ip filter file: %s:%u: %s", filename.c_str(), lineNumber, e.what()); diff --git a/src/rpc/parse_commands.cc b/src/rpc/parse_commands.cc index 34cb4c9c..06c74f7c 100644 --- a/src/rpc/parse_commands.cc +++ b/src/rpc/parse_commands.cc @@ -181,6 +181,11 @@ parse_command_file(const std::string& path) { getCount = 0; } + if (file.fail() && !file.eof()) { + lineNumber++; + throw torrent::input_error("Exceeded max line length."); + } + } catch (torrent::input_error& e) { snprintf(buffer, 2048, "Error in option file: %s:%u: %s", path.c_str(), lineNumber, e.what());