]> git.sesse.net Git - betaftpd/commitdiff
Fixed a few problems reported by Valgrind (still not sure if BetaFTPD is totally...
authorsgunderson <sgunderson>
Sat, 12 Apr 2003 12:43:40 +0000 (12:43 +0000)
committersgunderson <sgunderson>
Sat, 12 Apr 2003 12:43:40 +0000 (12:43 +0000)
cmds.c
ftpd.c

diff --git a/cmds.c b/cmds.c
index e1fe248f1cb3c5c9626119a619b95430e24c8830..2e38823ab9d4716ae5c2f6aae5805e513c819fca 100644 (file)
--- a/cmds.c
+++ b/cmds.c
@@ -1079,6 +1079,7 @@ int long_listing(char * const retbuf, const char * const pathname, const int do_
        }
 
        strcpy(retbuf, temp);
+       return 1;
 }
 
 /*
@@ -1605,9 +1606,7 @@ void parse_command(struct conn *c)
                                        }
                                }       
                                
-                               if (c->free_me) {
-                                       destroy_conn(c);
-                               } else {
+                               if (!c->free_me) {
                                        c->recv_buf[cmlen] = schar;
 #if !WANT_NONROOT
                                        if (h->do_setuid) {
diff --git a/ftpd.c b/ftpd.c
index 19816bfd489801da7c80087166d1563831b2ad31..a7234f8789dd073182e1fc019de00a24f8683cdb 100644 (file)
--- a/ftpd.c
+++ b/ftpd.c
@@ -446,6 +446,7 @@ struct ftran *alloc_new_ftran(const int sock, const struct conn * const c)
 #endif
 
        f->dir_listing = 0;
+       f->upload = 0;
        return f;
 }
 
@@ -583,7 +584,7 @@ int process_all_clients(const fd_set * const active_clients, const int num_ac)
                c->buf_len += bytes_avail;
                parse_command(c);
 
-               if (fds[c->sock].revents & (POLLERR|POLLHUP|POLLNVAL)) {
+               if (c->free_me || (fds[c->sock].revents & (POLLERR|POLLHUP|POLLNVAL))) {
                         destroy_conn(c);
                 }
        }
@@ -759,7 +760,7 @@ int do_upload(struct ftran *f)
 #endif
        if (size > 0 && (write(f->local_file, upload_buf, size) == size)) {
                return 1;
-       } else if (size == -1) {
+       } else if (size == -1 && errno != EAGAIN) {
                /* don't write xferlog... or? */
                numeric(f->owner, 426, strerror(errno));
                destroy_ftran(f);
@@ -1228,7 +1229,7 @@ void numeric(struct conn * const c, const int numeric, const char * const format
 {
        char fmt[256];
        va_list args;
-       int i, err;
+       int i;
        int in_buf = strlen(message_buf);
 
        snprintf(fmt, 256, "%03u %s\r\n", numeric, format);