]> git.sesse.net Git - betaftpd/blobdiff - ftpd.c
Fixed a few problems reported by Valgrind (still not sure if BetaFTPD is totally...
[betaftpd] / ftpd.c
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);