Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!floyd!harpo!decvax!ucbvax!ucbcad!tektronix!hplabs!sri-unix!cak@Purdue.ARPA From: cak@Purdue.ARPA Newsgroups: net.unix-wizards Subject: ftpd doesn't work on multi-homed hosts Message-ID: <273@sri-arpa.UUCP> Date: Sun, 25-Mar-84 21:18:00 EST Article-I.D.: sri-arpa.273 Posted: Sun Mar 25 21:18:00 1984 Date-Received: Fri, 30-Mar-84 00:33:39 EST Lines: 57 From: Christopher A Kent Description: On multi-homed hosts, ftpd won't always work because the code to anchor the reply socket is incorrect; the getsockname() call has a bad argument, thus the filled in address is always 0. Repeat-By: ftp to a multi-homed host on the same net as yours, but specify the alternate address as the host to connect to. Fix: getsockname() wants an int *, not an int, for the namelen. I did it this way (don't trust the line numbers): *** ftpd.c.old --- ftpd.c *************** *** 168,173 continue; } if (fork() == 0) { signal (SIGCHLD, SIG_IGN); openlog("ftpd", LOG_PID); dolog(&his_addr); --- 168,175 ----- continue; } if (fork() == 0) { + int addrsize; + signal (SIGCHLD, SIG_IGN); openlog("ftpd", LOG_PID); dolog(&his_addr); *************** *** 183,189 form = FORM_N; stru = STRU_F; mode = MODE_S; ! (void) getsockname(0, &ctrl_addr, sizeof (ctrl_addr)); gethostname(hostname, sizeof (hostname)); reply(220, "%s FTP server (%s) ready.", hostname, version); --- 185,192 ----- form = FORM_N; stru = STRU_F; mode = MODE_S; ! addrsize = sizeof(ctrl_addr); ! (void) getsockname(0, &ctrl_addr, &addrsize); gethostname(hostname, sizeof (hostname)); reply(220, "%s FTP server (%s) ready.", hostname, version); ----------