mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-13 05:32:31 +00:00
* Proper fault handling for bad SCGI requests.
* Cleaned up duplicate code in 'xmlrpc.cc'. * Cleaned up 'parse_commands.h'. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@966 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -97,8 +97,8 @@ void
|
||||
SCgiTask::event_read() {
|
||||
int bytes = ::recv(m_fileDesc, m_position, m_bufferSize - (m_position - m_buffer), 0);
|
||||
|
||||
if (bytes == -1) {
|
||||
if (!rak::error_number::current().is_blocked_momentary())
|
||||
if (bytes <= 0) {
|
||||
if (bytes == 0 || !rak::error_number::current().is_blocked_momentary())
|
||||
close();
|
||||
|
||||
return;
|
||||
@@ -116,10 +116,12 @@ SCgiTask::event_read() {
|
||||
int contentSize;
|
||||
int headerSize = strtol(m_buffer, ¤t, 0);
|
||||
|
||||
if (current == m_buffer || current == m_position)
|
||||
if (current == m_position)
|
||||
return;
|
||||
|
||||
if (*current != ':' || headerSize < 17 || headerSize > max_header_size)
|
||||
// If the request doesn't start with an integer or if it didn't
|
||||
// end in ':', then close the connection.
|
||||
if (current == m_buffer || *current != ':' || headerSize < 17 || headerSize > max_header_size)
|
||||
goto event_read_failed;
|
||||
|
||||
if (std::distance(++current, m_position) < headerSize + 1)
|
||||
@@ -171,7 +173,8 @@ SCgiTask::event_read() {
|
||||
return;
|
||||
|
||||
event_read_failed:
|
||||
throw torrent::internal_error("SCgiTask::event_read() fault not handled.");
|
||||
// throw torrent::internal_error("SCgiTask::event_read() fault not handled.");
|
||||
close();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user