gvfs r2245 - in trunk: . daemon



Author: otte
Date: Tue Feb 24 08:30:01 2009
New Revision: 2245
URL: http://svn.gnome.org/viewvc/gvfs?rev=2245&view=rev

Log:
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>



Modified:
   trunk/ChangeLog
   trunk/daemon/gvfsbackendftp.c

Modified: trunk/daemon/gvfsbackendftp.c
==============================================================================
--- trunk/daemon/gvfsbackendftp.c	(original)
+++ trunk/daemon/gvfsbackendftp.c	Tue Feb 24 08:30:01 2009
@@ -348,7 +348,6 @@
 			ResponseFlags  flags)
 {
   SoupSocketIOStatus status;
-  gsize n_bytes;
   gboolean got_boundary;
   char *last_line;
   enum {
@@ -368,6 +367,8 @@
     {
       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 @@
 
       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 @@
 	}
       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;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]