Bug in twoftpd 1.41 (patch attached)

Khalikov Anton <[email protected]> Sun, 18 Sep 2011 19:34:53 +0600
Newsgroups gmane.comp.sysutils.bgware
Message-ID <[email protected]>
--Apple-Mail=_D3A110A4-D127-4957-8BCD-24D1C4EB750C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

Hello there

We've found a bug in twoftpd 1.41. When executing LIST on a non existing =
file, it answers "550 Could not access file." AND opens data connection =
which contains no data. This is wrong and this behavior breaks some ftp =
clients such as FAR Manager.

The problem is in list.c, handle_listing() function. Please see attached =
patch.

--Apple-Mail=_D3A110A4-D127-4957-8BCD-24D1C4EB750C
Content-Disposition: attachment;
	filename=0009-fix-list-data-connection.diff
Content-Type: application/octet-stream;
	name="0009-fix-list-data-connection.diff"
Content-Transfer-Encoding: 7bit

--- twoftpd-1.41/list.c.orig	2011-09-18 13:08:13.732516100 +0000
+++ twoftpd-1.41/list.c	2011-09-18 13:10:13.220516060 +0000
@@ -272,7 +272,7 @@
 
 static int handle_listing(int longfmt)
 {
-  int result;
+  //int result;
   struct stat statbuf;
   long count;
   int striplen;
@@ -329,9 +329,9 @@
 
     if (stat(entries.s, &statbuf) == -1) {
       if (errno == EEXIST)
-	result = respond(550, 1, "File or directory does not exist.");
+	return respond(550, 1, "File or directory does not exist.");
       else
-	result = respond(550, 1, "Could not access file.");
+	return respond(550, 1, "Could not access file.");
     }
     else if (S_ISDIR(statbuf.st_mode)) {
       if (!str_copys(&fullpath, "/") ||

--Apple-Mail=_D3A110A4-D127-4957-8BCD-24D1C4EB750C
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=us-ascii


---
Best regards
Anton Khalikov



--Apple-Mail=_D3A110A4-D127-4957-8BCD-24D1C4EB750C
Content-Type: text/plain; charset=us-ascii


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
--Apple-Mail=_D3A110A4-D127-4957-8BCD-24D1C4EB750C--