Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: net/ftp/ftp_network_transaction.cc

Issue 146137: Hang if directory listing size is > 8k (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_network_transaction.cc
===================================================================
--- net/ftp/ftp_network_transaction.cc (revision 19238)
+++ net/ftp/ftp_network_transaction.cc (working copy)
@@ -88,22 +88,15 @@
DCHECK(buf);
DCHECK(buf_len > 0);
- if (data_socket_ == NULL)
- return 0; // Data socket closed, no more data left.
-
- if (!data_socket_->IsConnected())
- return 0; // Data socket disconnected, no more data left.
-
read_data_buf_ = buf;
- read_data_buf_len_ = buf_len;
-
+ // Always read one byte less than the size, because if data is directory
+ // listing then we must have a null terminating string.
+ read_data_buf_len_ = buf_len - 1;
next_state_ = STATE_DATA_READ;
int rv = DoLoop(OK);
if (rv == ERR_IO_PENDING)
user_callback_ = callback;
- else if (rv == 0)
- data_socket_->Disconnect();
return rv;
}
@@ -795,8 +788,8 @@
int FtpNetworkTransaction::ProcessResponseLIST(int response_code) {
switch (GetErrorClass(response_code)) {
case ERROR_CLASS_INITIATED:
+ response_.is_directory_listing = true;
response_message_buf_len_ = 0; // Clear the responce buffer.
- next_state_ = STATE_CTRL_READ;
break;
case ERROR_CLASS_OK:
response_.is_directory_listing = true;
@@ -865,6 +858,9 @@
}
int FtpNetworkTransaction::DoDataRead() {
+ if (data_socket_ == NULL || !data_socket_->IsConnected())
+ return Stop(OK); // No more data so send QUIT Command now and wait for response.
+
DCHECK(read_data_buf_);
DCHECK(read_data_buf_len_ > 0);
@@ -875,8 +871,6 @@
}
int FtpNetworkTransaction::DoDataReadComplete(int result) {
- DLOG(INFO) << read_data_buf_->data(); // The read_data_buf_ is NULL
- // terminated string.
return result;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698