I ran betaftpd under valgrind and stressed it out with
dkftpbench with over 500 users, then killed dkftpbench.
This caused numerous problems to be reported by valgrind.
There were two root causes:
1. list nodes having uninitialized next or prev pointers.
This was simple to fix, just had to always initialize them to 0.
Only alloc_new_conn and alloc_new_ftran needed fixing.
2. parse_command calls command handlers, then unless the handler
returned 0 to indicate a destroyed connection, it references
the connection again. However, many handlers call numeric(),
which can destroy the connection it's being called on.
The "solution" is to make numeric return the same sort of value
that the handlers do, and have the handlers return numeric's
return value. More or less.
Not quite sure if the fix I did was correct, but it doesn't
fail like it used to under my little stress test.
The fix is at
http://kegel.com/dkbetaftpd/betaftpd-numeric.patch