summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2009-02-24 08:30:01 +0000
committerBenjamin Otte <otte@src.gnome.org>2009-02-24 08:30:01 +0000
commit97b250591d51a5f13a51b2a7fc22c45fb0ccf004 (patch)
tree797975050f163fd3d9be9e11a54367ecbc547bdc /daemon
parent68457da9d262ede717f0c005b67b5d827a755240 (diff)
downloadgvfs-97b250591d51a5f13a51b2a7fc22c45fb0ccf004.tar.gz
Bug 525283 - handle short reads in ftp
2009-02-24 Benjamin Otte <otte@gnome.org> Bug 525283 - handle short reads in ftp * daemon/gvfsbackendftp.c: (ftp_connection_receive): fix usage of n_bytes variable that changed meaning with the last ftp fixes. Spotted by Filippo Argiolas <filippo.argiolas@gmail.com> svn path=/trunk/; revision=2245
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfsbackendftp.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index 4c2aad1f..5009d5b4 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -348,7 +348,6 @@ ftp_connection_receive (FtpConnection *conn,
ResponseFlags flags)
{
SoupSocketIOStatus status;
- gsize n_bytes;
gboolean got_boundary;
char *last_line;
enum {
@@ -368,6 +367,8 @@ ftp_connection_receive (FtpConnection *conn,
{
last_line = conn->read_buffer + conn->read_bytes;
do {
+ gsize n_bytes;
+
/* the available size must at least allow for boundary size (2)
* bytes to be available for reading */
if (conn->read_buffer_size - conn->read_bytes < 128)
@@ -419,8 +420,7 @@ ftp_connection_receive (FtpConnection *conn,
if (reply_state == FIRST_LINE)
{
- if (n_bytes < 4 ||
- last_line[0] <= '0' || last_line[0] > '5' ||
+ if (last_line[0] <= '0' || last_line[0] > '5' ||
last_line[1] < '0' || last_line[1] > '9' ||
last_line[2] < '0' || last_line[2] > '9')
{
@@ -444,8 +444,9 @@ ftp_connection_receive (FtpConnection *conn,
}
else
{
- if (n_bytes >= 4 &&
- memcmp (conn->read_buffer, last_line, 3) == 0 &&
+ if (last_line[0] == conn->read_buffer[0] &&
+ last_line[1] == conn->read_buffer[1] &&
+ last_line[2] == conn->read_buffer[2] &&
last_line[3] == ' ')
reply_state = DONE;
}