From: sgunderson Date: Sat, 12 Apr 2003 12:43:40 +0000 (+0000) Subject: Fixed a few problems reported by Valgrind (still not sure if BetaFTPD is totally... X-Git-Url: https://git.sesse.net/?p=betaftpd;a=commitdiff_plain;h=36a3d95e46fd6b07fb8a2dfc30ec37c21b34b41a Fixed a few problems reported by Valgrind (still not sure if BetaFTPD is totally Valgrind-clean, though). --- diff --git a/cmds.c b/cmds.c index e1fe248..2e38823 100644 --- 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 19816bf..a7234f8 100644 --- 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);