Author: R. Koucha
Last update:04-Mar-2011

Patch to fix the crash of FTPD in debug mode






When we run ftpd in debug mode (option --debug on the command line), the server crashes upon incoming connections. The bug comes from the functions reply() and lreply() in the file ftpd/ftpd.c: they don't "reset" the "va_list" before calling syslog(). So, the latter gets the end of the list of arguments. This triggers a crash on my PowerPc based target !


Please apply the following patch:

diff -Naurp OLD/ftpd/ftpd.c NEW/ftpd/ftpd.c
--- OLD/ftpd/ftpd.c 2011-03-03 19:07:26.449998496 +0100
+++ NEW/ftpd/ftpd.c 2011-03-03 19:09:12.696935892 +0100
@@ -1483,10 +1483,13 @@ reply (int n, const char *fmt, ...)
vprintf (fmt, ap);
printf ("\r\n");
fflush (stdout);
+ va_end(ap);
if (debug)
{
syslog (LOG_DEBUG, "<--- %d ", n);
+ va_start (ap, fmt);
vsyslog (LOG_DEBUG, fmt, ap);
+ va_end(ap);
}
}

@@ -1499,10 +1502,13 @@ lreply (int n, const char *fmt, ...)
vprintf (fmt, ap);
printf ("\r\n");
fflush (stdout);
+ va_end(ap);
if (debug)
{
syslog (LOG_DEBUG, "<--- %d- ", n);
+ va_start (ap, fmt);
vsyslog (LOG_DEBUG, fmt, ap);
+ va_end(ap);
}
}

About the author

The author is an engineer in computer sciences located in France. He is glad to graciously offer this utility under the GPL open source license. He can be contacted through this page or you can have a look at his WEB home page.