=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/ftp.c,v retrieving revision 1.10 retrieving revision 1.11 diff -c -r1.10 -r1.11 *** src/usr.bin/ftp/ftp.c 1997/02/03 01:02:39 1.10 --- src/usr.bin/ftp/ftp.c 1997/02/03 01:05:40 1.11 *************** *** 1,3 **** --- 1,4 ---- + /* $OpenBSD: ftp.c,v 1.11 1997/02/03 01:05:40 millert Exp $ */ /* $NetBSD: ftp.c,v 1.22 1997/02/01 10:45:03 lukem Exp $ */ /* *************** *** 37,43 **** #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else ! static char rcsid[] = "$NetBSD: ftp.c,v 1.22 1997/02/01 10:45:03 lukem Exp $"; #endif #endif /* not lint */ --- 38,44 ---- #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else ! static char rcsid[] = "$OpenBSD: ftp.c,v 1.11 1997/02/03 01:05:40 millert Exp $"; #endif #endif /* not lint */ *************** *** 87,96 **** int s, len, tos; static char hostnamebuf[MAXHOSTNAMELEN]; ! memset((char *)&hisctladdr, 0, sizeof (hisctladdr)); if (inet_aton(host, &hisctladdr.sin_addr) != 0) { hisctladdr.sin_family = AF_INET; ! (void) strncpy(hostnamebuf, host, sizeof(hostnamebuf)); } else { hp = gethostbyname(host); if (hp == NULL) { --- 88,98 ---- int s, len, tos; static char hostnamebuf[MAXHOSTNAMELEN]; ! memset((char *)&hisctladdr, 0, sizeof(hisctladdr)); if (inet_aton(host, &hisctladdr.sin_addr) != 0) { hisctladdr.sin_family = AF_INET; ! (void)strncpy(hostnamebuf, host, sizeof(hostnamebuf) - 1); ! hostnamebuf[sizeof(hostnamebuf) - 1] = '\0'; } else { hp = gethostbyname(host); if (hp == NULL) { *************** *** 99,108 **** return ((char *) 0); } hisctladdr.sin_family = hp->h_addrtype; ! memmove((caddr_t)&hisctladdr.sin_addr, ! hp->h_addr_list[0], hp->h_length); ! memcpy(&hisctladdr.sin_addr, hp->h_addr, hp->h_length); ! (void) strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf)); } hostname = hostnamebuf; s = socket(hisctladdr.sin_family, SOCK_STREAM, 0); --- 101,109 ---- return ((char *) 0); } hisctladdr.sin_family = hp->h_addrtype; ! memcpy(&hisctladdr.sin_addr, hp->h_addr_list[0], hp->h_length); ! (void)strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf) - 1); ! hostnamebuf[sizeof(hostnamebuf) - 1] = '\0'; } hostname = hostnamebuf; s = socket(hisctladdr.sin_family, SOCK_STREAM, 0); *************** *** 113,119 **** } hisctladdr.sin_port = port; while (connect(s, (struct sockaddr *)&hisctladdr, ! sizeof (hisctladdr)) < 0) { if (hp && hp->h_addr_list[1]) { int oerrno = errno; char *ia; --- 114,120 ---- } hisctladdr.sin_port = port; while (connect(s, (struct sockaddr *)&hisctladdr, ! sizeof(hisctladdr)) < 0) { if (hp && hp->h_addr_list[1]) { int oerrno = errno; char *ia; *************** *** 122,132 **** errno = oerrno; warn("connect to address %s", ia); hp->h_addr_list++; ! memmove((caddr_t)&hisctladdr.sin_addr, ! hp->h_addr_list[0], hp->h_length); ! fprintf(stdout, "Trying %s...\n", ! inet_ntoa(hisctladdr.sin_addr)); ! (void) close(s); s = socket(hisctladdr.sin_family, SOCK_STREAM, 0); if (s < 0) { warn("socket"); --- 123,132 ---- errno = oerrno; warn("connect to address %s", ia); hp->h_addr_list++; ! memcpy(&hisctladdr.sin_addr, hp->h_addr_list[0], ! hp->h_length); ! printf("Trying %s...\n", inet_ntoa(hisctladdr.sin_addr)); ! (void)close(s); s = socket(hisctladdr.sin_family, SOCK_STREAM, 0); if (s < 0) { warn("socket"); *************** *** 139,145 **** code = -1; goto bad; } ! len = sizeof (myctladdr); if (getsockname(s, (struct sockaddr *)&myctladdr, &len) < 0) { warn("getsockname"); code = -1; --- 139,145 ---- code = -1; goto bad; } ! len = sizeof(myctladdr); if (getsockname(s, (struct sockaddr *)&myctladdr, &len) < 0) { warn("getsockname"); code = -1; *************** *** 155,163 **** if (cin == NULL || cout == NULL) { warnx("fdopen failed."); if (cin) ! (void) fclose(cin); if (cout) ! (void) fclose(cout); code = -1; goto bad; } --- 155,163 ---- if (cin == NULL || cout == NULL) { warnx("fdopen failed."); if (cin) ! (void)fclose(cin); if (cout) ! (void)fclose(cout); code = -1; goto bad; } *************** *** 165,173 **** printf("Connected to %s.\n", hostname); if (getreply(0) > 2) { /* read startup message from server */ if (cin) ! (void) fclose(cin); if (cout) ! (void) fclose(cout); code = -1; goto bad; } --- 165,173 ---- printf("Connected to %s.\n", hostname); if (getreply(0) > 2) { /* read startup message from server */ if (cin) ! (void)fclose(cin); if (cout) ! (void)fclose(cout); code = -1; goto bad; } *************** *** 184,190 **** return (hostname); bad: ! (void) close(s); return ((char *)0); } --- 184,190 ---- return (hostname); bad: ! (void)close(s); return ((char *)0); } *************** *** 247,253 **** printf("Name (%s:%s): ", host, myname); else printf("Name (%s): ", host); ! (void) fgets(tmp, sizeof(tmp) - 1, stdin); tmp[strlen(tmp) - 1] = '\0'; if (*tmp == '\0') user = myname; --- 247,253 ---- printf("Name (%s:%s): ", host, myname); else printf("Name (%s): ", host); ! (void)fgets(tmp, sizeof(tmp) - 1, stdin); tmp[strlen(tmp) - 1] = '\0'; if (*tmp == '\0') user = myname; *************** *** 270,281 **** return (0); } if (!aflag && acct != NULL) ! (void) command("ACCT %s", acct); if (proxy) return (1); for (n = 0; n < macnum; ++n) { if (!strcmp("init", macros[n].mac_name)) { ! (void) strcpy(line, "$init"); makeargv(); domacro(margc, margv); break; --- 270,281 ---- return (0); } if (!aflag && acct != NULL) ! (void)command("ACCT %s", acct); if (proxy) return (1); for (n = 0; n < macnum; ++n) { if (!strcmp("init", macros[n].mac_name)) { ! (void)strcpy(line, "$init"); makeargv(); domacro(margc, margv); break; *************** *** 289,296 **** { alarmtimer(0); ! printf("\n"); ! (void) fflush(stdout); abrtflag++; if (ptflag) longjmp(ptabort, 1); --- 289,296 ---- { alarmtimer(0); ! putchar('\n'); ! (void)fflush(stdout); abrtflag++; if (ptflag) longjmp(ptabort, 1); *************** *** 308,325 **** abrtflag = 0; if (debug) { ! printf("---> "); va_start(ap); fmt = va_arg(ap, char *); if (strncmp("PASS ", fmt, 5) == 0) ! printf("PASS XXXX"); else if (strncmp("ACCT ", fmt, 5) == 0) ! printf("ACCT XXXX"); else ! vfprintf(stdout, fmt, ap); va_end(ap); ! printf("\n"); ! (void) fflush(stdout); } if (cout == NULL) { warn("No control connection for command"); --- 308,325 ---- abrtflag = 0; if (debug) { ! fputs("---> ", stdout); va_start(ap); fmt = va_arg(ap, char *); if (strncmp("PASS ", fmt, 5) == 0) ! fputs("PASS XXXX", stdout); else if (strncmp("ACCT ", fmt, 5) == 0) ! fputs("ACCT XXXX", stdout); else ! vprintf(fmt, ap); va_end(ap); ! putchar('\n'); ! (void)fflush(stdout); } if (cout == NULL) { warn("No control connection for command"); *************** *** 331,343 **** fmt = va_arg(ap, char *); vfprintf(cout, fmt, ap); va_end(ap); ! fprintf(cout, "\r\n"); ! (void) fflush(cout); cpend = 1; r = getreply(!strcmp(fmt, "QUIT")); if (abrtflag && oldintr != SIG_IGN) (*oldintr)(SIGINT); ! (void) signal(SIGINT, oldintr); return (r); } --- 331,343 ---- fmt = va_arg(ap, char *); vfprintf(cout, fmt, ap); va_end(ap); ! fputs("\r\n", cout); ! (void)fflush(cout); cpend = 1; r = getreply(!strcmp(fmt, "QUIT")); if (abrtflag && oldintr != SIG_IGN) (*oldintr)(SIGINT); ! (void)signal(SIGINT, oldintr); return (r); } *************** *** 366,378 **** case WONT: c = getc(cin); fprintf(cout, "%c%c%c", IAC, DONT, c); ! (void) fflush(cout); break; case DO: case DONT: c = getc(cin); fprintf(cout, "%c%c%c", IAC, WONT, c); ! (void) fflush(cout); break; default: break; --- 366,378 ---- case WONT: c = getc(cin); fprintf(cout, "%c%c%c", IAC, DONT, c); ! (void)fflush(cout); break; case DO: case DONT: c = getc(cin); fprintf(cout, "%c%c%c", IAC, WONT, c); ! (void)fflush(cout); break; default: break; *************** *** 382,407 **** dig++; if (c == EOF) { if (expecteof) { ! (void) signal(SIGINT, oldintr); code = 221; return (0); } lostpeer(); if (verbose) { ! printf("421 Service not available, " ! "remote server has closed " ! "connection\n"); ! (void) fflush(stdout); } code = 421; return (4); } if (c != '\r' && (verbose > 0 || ! (verbose > -1 && n == '5' && dig > 4))) { if (proxflag && (dig == 1 || (dig == 5 && verbose == 0))) printf("%s:", hostname); ! (void) putchar(c); } if (dig < 4 && isdigit(c)) code = code * 10 + (c - '0'); --- 382,407 ---- dig++; if (c == EOF) { if (expecteof) { ! (void)signal(SIGINT, oldintr); code = 221; return (0); } lostpeer(); if (verbose) { ! puts( ! "421 Service not available, remote server has closed connection"); ! (void)fflush(stdout); } code = 421; return (4); } if (c != '\r' && (verbose > 0 || ! (verbose > -1 && n == '5' && dig > 4)) && ! (n < '5' || !retry_connect)) { if (proxflag && (dig == 1 || (dig == 5 && verbose == 0))) printf("%s:", hostname); ! (void)putchar(c); } if (dig < 4 && isdigit(c)) code = code * 10 + (c - '0'); *************** *** 427,435 **** if (cp < ¤t_line[sizeof(current_line) - 1]) *cp++ = c; } ! if (verbose > 0 || (verbose > -1 && n == '5')) { ! (void) putchar(c); ! (void) fflush (stdout); } if (line == 0) { size_t len = cp - current_line; --- 427,436 ---- if (cp < ¤t_line[sizeof(current_line) - 1]) *cp++ = c; } ! if (verbose > 0 || ((verbose > -1 && n == '5') && ! (n < '5' || !retry_connect))) { ! (void)putchar(c); ! (void)fflush (stdout); } if (line == 0) { size_t len = cp - current_line; *************** *** 437,443 **** if (len > sizeof(reply_string)) len = sizeof(reply_string); ! (void) strncpy(reply_string, current_line, len); reply_string[len] = '\0'; } if (continuation && code != originalcode) { --- 438,444 ---- if (len > sizeof(reply_string)) len = sizeof(reply_string); ! (void)strncpy(reply_string, current_line, len); reply_string[len] = '\0'; } if (continuation && code != originalcode) { *************** *** 448,454 **** *cp = '\0'; if (n != '1') cpend = 0; ! (void) signal(SIGINT, oldintr); if (code == 421 || originalcode == 421) lostpeer(); if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN) --- 449,455 ---- *cp = '\0'; if (n != '1') cpend = 0; ! (void)signal(SIGINT, oldintr); if (code == 421 || originalcode == 421) lostpeer(); if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN) *************** *** 478,485 **** alarmtimer(0); mflag = 0; abrtflag = 0; ! printf("\nsend aborted\nwaiting for remote to finish abort\n"); ! (void) fflush(stdout); longjmp(sendabort, 1); } --- 479,486 ---- alarmtimer(0); mflag = 0; abrtflag = 0; ! puts("\nsend aborted\nwaiting for remote to finish abort"); ! (void)fflush(stdout); longjmp(sendabort, 1); } *************** *** 519,536 **** lmode = "w"; if (setjmp(sendabort)) { while (cpend) { ! (void) getreply(0); } if (data >= 0) { ! (void) close(data); data = -1; } if (oldintr) ! (void) signal(SIGINT, oldintr); if (oldintp) ! (void) signal(SIGPIPE, oldintp); if (oldinti) ! (void) signal(SIGINFO, oldinti); code = -1; return; } --- 520,537 ---- lmode = "w"; if (setjmp(sendabort)) { while (cpend) { ! (void)getreply(0); } if (data >= 0) { ! (void)close(data); data = -1; } if (oldintr) ! (void)signal(SIGINT, oldintr); if (oldintp) ! (void)signal(SIGPIPE, oldintp); if (oldinti) ! (void)signal(SIGINFO, oldinti); code = -1; return; } *************** *** 543,551 **** fin = popen(local + 1, "r"); if (fin == NULL) { warn("%s", local + 1); ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGPIPE, oldintp); ! (void) signal(SIGINFO, oldinti); code = -1; return; } --- 544,552 ---- fin = popen(local + 1, "r"); if (fin == NULL) { warn("%s", local + 1); ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGPIPE, oldintp); ! (void)signal(SIGINFO, oldinti); code = -1; return; } *************** *** 554,570 **** fin = fopen(local, "r"); if (fin == NULL) { warn("local: %s", local); ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); code = -1; return; } closefunc = fclose; if (fstat(fileno(fin), &st) < 0 || (st.st_mode&S_IFMT) != S_IFREG) { ! fprintf(stdout, "%s: not a plain file.\n", local); ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); fclose(fin); code = -1; return; --- 555,571 ---- fin = fopen(local, "r"); if (fin == NULL) { warn("local: %s", local); ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); code = -1; return; } closefunc = fclose; if (fstat(fileno(fin), &st) < 0 || (st.st_mode&S_IFMT) != S_IFREG) { ! printf("%s: not a plain file.\n", local); ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); fclose(fin); code = -1; return; *************** *** 572,581 **** filesize = st.st_size; } if (initconn()) { ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); if (oldintp) ! (void) signal(SIGPIPE, oldintp); code = -1; if (closefunc != NULL) (*closefunc)(fin); --- 573,582 ---- filesize = st.st_size; } if (initconn()) { ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); if (oldintp) ! (void)signal(SIGPIPE, oldintp); code = -1; if (closefunc != NULL) (*closefunc)(fin); *************** *** 617,636 **** } if (remote) { if (command("%s %s", cmd, remote) != PRELIM) { ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); if (oldintp) ! (void) signal(SIGPIPE, oldintp); if (closefunc != NULL) (*closefunc)(fin); return; } } else if (command("%s", cmd) != PRELIM) { ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); if (oldintp) ! (void) signal(SIGPIPE, oldintp); if (closefunc != NULL) (*closefunc)(fin); return; --- 618,637 ---- } if (remote) { if (command("%s %s", cmd, remote) != PRELIM) { ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); if (oldintp) ! (void)signal(SIGPIPE, oldintp); if (closefunc != NULL) (*closefunc)(fin); return; } } else if (command("%s", cmd) != PRELIM) { ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); if (oldintp) ! (void)signal(SIGPIPE, oldintp); if (closefunc != NULL) (*closefunc)(fin); return; *************** *** 645,668 **** case TYPE_I: case TYPE_L: errno = d = 0; ! while ((c = read(fileno(fin), buf, sizeof (buf))) > 0) { bytes += c; for (bufp = buf; c > 0; c -= d, bufp += d) if ((d = write(fileno(dout), bufp, c)) <= 0) break; if (hash && (!progress || filesize < 0) ) { while (bytes >= hashbytes) { ! (void) putchar('#'); hashbytes += mark; } ! (void) fflush(stdout); } } if (hash && (!progress || filesize < 0) && bytes > 0) { if (bytes < mark) ! (void) putchar('#'); ! (void) putchar('\n'); ! (void) fflush(stdout); } if (c < 0) warn("local: %s", local); --- 646,669 ---- case TYPE_I: case TYPE_L: errno = d = 0; ! while ((c = read(fileno(fin), buf, sizeof(buf))) > 0) { bytes += c; for (bufp = buf; c > 0; c -= d, bufp += d) if ((d = write(fileno(dout), bufp, c)) <= 0) break; if (hash && (!progress || filesize < 0) ) { while (bytes >= hashbytes) { ! (void)putchar('#'); hashbytes += mark; } ! (void)fflush(stdout); } } if (hash && (!progress || filesize < 0) && bytes > 0) { if (bytes < mark) ! (void)putchar('#'); ! (void)putchar('\n'); ! (void)fflush(stdout); } if (c < 0) warn("local: %s", local); *************** *** 678,693 **** if (c == '\n') { while (hash && (!progress || filesize < 0) && (bytes >= hashbytes)) { ! (void) putchar('#'); ! (void) fflush(stdout); hashbytes += mark; } if (ferror(dout)) break; ! (void) putc('\r', dout); bytes++; } ! (void) putc(c, dout); bytes++; #if 0 /* this violates RFC */ if (c == '\r') { --- 679,694 ---- if (c == '\n') { while (hash && (!progress || filesize < 0) && (bytes >= hashbytes)) { ! (void)putchar('#'); ! (void)fflush(stdout); hashbytes += mark; } if (ferror(dout)) break; ! (void)putc('\r', dout); bytes++; } ! (void)putc(c, dout); bytes++; #if 0 /* this violates RFC */ if (c == '\r') { *************** *** 698,706 **** } if (hash && (!progress || filesize < 0)) { if (bytes < hashbytes) ! (void) putchar('#'); ! (void) putchar('\n'); ! (void) fflush(stdout); } if (ferror(fin)) warn("local: %s", local); --- 699,707 ---- } if (hash && (!progress || filesize < 0)) { if (bytes < hashbytes) ! (void)putchar('#'); ! (void)putchar('\n'); ! (void)fflush(stdout); } if (ferror(fin)) warn("local: %s", local); *************** *** 714,744 **** progressmeter(1); if (closefunc != NULL) (*closefunc)(fin); ! (void) fclose(dout); ! (void) getreply(0); ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); if (oldintp) ! (void) signal(SIGPIPE, oldintp); if (bytes > 0) ptransfer(0); return; abort: ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); if (oldintp) ! (void) signal(SIGPIPE, oldintp); if (!cpend) { code = -1; return; } if (data >= 0) { ! (void) close(data); data = -1; } if (dout) ! (void) fclose(dout); ! (void) getreply(0); code = -1; if (closefunc != NULL && fin != NULL) (*closefunc)(fin); --- 715,745 ---- progressmeter(1); if (closefunc != NULL) (*closefunc)(fin); ! (void)fclose(dout); ! (void)getreply(0); ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); if (oldintp) ! (void)signal(SIGPIPE, oldintp); if (bytes > 0) ptransfer(0); return; abort: ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); if (oldintp) ! (void)signal(SIGPIPE, oldintp); if (!cpend) { code = -1; return; } if (data >= 0) { ! (void)close(data); data = -1; } if (dout) ! (void)fclose(dout); ! (void)getreply(0); code = -1; if (closefunc != NULL && fin != NULL) (*closefunc)(fin); *************** *** 755,762 **** alarmtimer(0); mflag = 0; abrtflag = 0; ! printf("\nreceive aborted\nwaiting for remote to finish abort\n"); ! (void) fflush(stdout); longjmp(recvabort, 1); } --- 756,763 ---- alarmtimer(0); mflag = 0; abrtflag = 0; ! puts("\nreceive aborted\nwaiting for remote to finish abort"); ! (void)fflush(stdout); longjmp(recvabort, 1); } *************** *** 797,812 **** tcrflag = !crflag && is_retr; if (setjmp(recvabort)) { while (cpend) { ! (void) getreply(0); } if (data >= 0) { ! (void) close(data); data = -1; } if (oldintr) ! (void) signal(SIGINT, oldintr); if (oldinti) ! (void) signal(SIGINFO, oldinti); code = -1; return; } --- 798,813 ---- tcrflag = !crflag && is_retr; if (setjmp(recvabort)) { while (cpend) { ! (void)getreply(0); } if (data >= 0) { ! (void)close(data); data = -1; } if (oldintr) ! (void)signal(SIGINT, oldintr); if (oldinti) ! (void)signal(SIGINFO, oldinti); code = -1; return; } *************** *** 818,825 **** if (errno != ENOENT && errno != EACCES) { warn("local: %s", local); ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); code = -1; return; } --- 819,826 ---- if (errno != ENOENT && errno != EACCES) { warn("local: %s", local); ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); code = -1; return; } *************** *** 830,859 **** *dir = '/'; if (d < 0) { warn("local: %s", local); ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); code = -1; return; } if (!runique && errno == EACCES && chmod(local, 0600) < 0) { warn("local: %s", local); ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); code = -1; return; } if (runique && errno == EACCES && (local = gunique(local)) == NULL) { ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); code = -1; return; } } else if (runique && (local = gunique(local)) == NULL) { ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); code = -1; return; } --- 831,860 ---- *dir = '/'; if (d < 0) { warn("local: %s", local); ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); code = -1; return; } if (!runique && errno == EACCES && chmod(local, 0600) < 0) { warn("local: %s", local); ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); code = -1; return; } if (runique && errno == EACCES && (local = gunique(local)) == NULL) { ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); code = -1; return; } } else if (runique && (local = gunique(local)) == NULL) { ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); code = -1; return; } *************** *** 867,874 **** filesize = remotesize(remote, 0); } if (initconn()) { ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); code = -1; return; } --- 868,875 ---- filesize = remotesize(remote, 0); } if (initconn()) { ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); code = -1; return; } *************** *** 879,892 **** return; if (remote) { if (command("%s %s", cmd, remote) != PRELIM) { ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); return; } } else { if (command("%s", cmd) != PRELIM) { ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); return; } } --- 880,893 ---- return; if (remote) { if (command("%s %s", cmd, remote) != PRELIM) { ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); return; } } else { if (command("%s", cmd) != PRELIM) { ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); return; } } *************** *** 915,921 **** st.st_blksize = BUFSIZ; if (st.st_blksize > bufsize) { if (buf) ! (void) free(buf); buf = malloc((unsigned)st.st_blksize); if (buf == NULL) { warn("malloc"); --- 916,922 ---- st.st_blksize = BUFSIZ; if (st.st_blksize > bufsize) { if (buf) ! (void)free(buf); buf = malloc((unsigned)st.st_blksize); if (buf == NULL) { warn("malloc"); *************** *** 943,959 **** bytes += c; if (hash && (!progress || filesize < 0)) { while (bytes >= hashbytes) { ! (void) putchar('#'); hashbytes += mark; } ! (void) fflush(stdout); } } if (hash && (!progress || filesize < 0) && bytes > 0) { if (bytes < mark) ! (void) putchar('#'); ! (void) putchar('\n'); ! (void) fflush(stdout); } if (c < 0) { if (errno != EPIPE) --- 944,960 ---- bytes += c; if (hash && (!progress || filesize < 0)) { while (bytes >= hashbytes) { ! (void)putchar('#'); hashbytes += mark; } ! (void)fflush(stdout); } } if (hash && (!progress || filesize < 0) && bytes > 0) { if (bytes < mark) ! (void)putchar('#'); ! (void)putchar('\n'); ! (void)fflush(stdout); } if (c < 0) { if (errno != EPIPE) *************** *** 995,1009 **** while (c == '\r') { while (hash && (!progress || filesize < 0) && (bytes >= hashbytes)) { ! (void) putchar('#'); ! (void) fflush(stdout); hashbytes += mark; } bytes++; if ((c = getc(din)) != '\n' || tcrflag) { if (ferror(fout)) goto break2; ! (void) putc('\r', fout); if (c == '\0') { bytes++; goto contin2; --- 996,1010 ---- while (c == '\r') { while (hash && (!progress || filesize < 0) && (bytes >= hashbytes)) { ! (void)putchar('#'); ! (void)fflush(stdout); hashbytes += mark; } bytes++; if ((c = getc(din)) != '\n' || tcrflag) { if (ferror(fout)) goto break2; ! (void)putc('\r', fout); if (c == '\0') { bytes++; goto contin2; *************** *** 1012,1032 **** goto contin2; } } ! (void) putc(c, fout); bytes++; contin2: ; } break2: if (bare_lfs) { ! printf("WARNING! %d bare linefeeds received in ASCII " ! "mode\n", bare_lfs); ! printf("File may not have transferred correctly.\n"); } if (hash && (!progress || filesize < 0)) { if (bytes < hashbytes) ! (void) putchar('#'); ! (void) putchar('\n'); ! (void) fflush(stdout); } if (ferror(din)) { if (errno != EPIPE) --- 1013,1033 ---- goto contin2; } } ! (void)putc(c, fout); bytes++; contin2: ; } break2: if (bare_lfs) { ! printf("WARNING! %d bare linefeeds received in ASCII mode\n", ! bare_lfs); ! puts("File may not have transferred correctly."); } if (hash && (!progress || filesize < 0)) { if (bytes < hashbytes) ! (void)putchar('#'); ! (void)putchar('\n'); ! (void)fflush(stdout); } if (ferror(din)) { if (errno != EPIPE) *************** *** 1040,1065 **** progressmeter(1); if (closefunc != NULL) (*closefunc)(fout); ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); if (oldintp) ! (void) signal(SIGPIPE, oldintp); ! (void) fclose(din); ! (void) getreply(0); if (bytes >= 0 && is_retr) { if (bytes > 0) ptransfer(0); if (preserve && (closefunc == fclose)) { mtime = remotemodtime(remote, 0); if (mtime != -1) { ! (void) gettimeofday(&tval[0], (struct timezone *)0); tval[1].tv_sec = mtime; tval[1].tv_usec = 0; if (utimes(local, tval) == -1) { ! printf("Can't change modification time " ! "on %s to %s", local, ! asctime(localtime(&mtime))); } } } --- 1041,1065 ---- progressmeter(1); if (closefunc != NULL) (*closefunc)(fout); ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); if (oldintp) ! (void)signal(SIGPIPE, oldintp); ! (void)fclose(din); ! (void)getreply(0); if (bytes >= 0 && is_retr) { if (bytes > 0) ptransfer(0); if (preserve && (closefunc == fclose)) { mtime = remotemodtime(remote, 0); if (mtime != -1) { ! (void)gettimeofday(&tval[0], (struct timezone *)0); tval[1].tv_sec = mtime; tval[1].tv_usec = 0; if (utimes(local, tval) == -1) { ! printf("Can't change modification time on %s to %s", ! local, asctime(localtime(&mtime))); } } } *************** *** 1070,1098 **** /* abort using RFC959 recommended IP,SYNC sequence */ if (oldintp) ! (void) signal(SIGPIPE, oldintp); ! (void) signal(SIGINT, SIG_IGN); if (!cpend) { code = -1; ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); return; } abort_remote(din); code = -1; if (data >= 0) { ! (void) close(data); data = -1; } if (closefunc != NULL && fout != NULL) (*closefunc)(fout); if (din) ! (void) fclose(din); if (bytes > 0) ptransfer(0); ! (void) signal(SIGINT, oldintr); ! (void) signal(SIGINFO, oldinti); } /* --- 1070,1098 ---- /* abort using RFC959 recommended IP,SYNC sequence */ if (oldintp) ! (void)signal(SIGPIPE, oldintp); ! (void)signal(SIGINT, SIG_IGN); if (!cpend) { code = -1; ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); return; } abort_remote(din); code = -1; if (data >= 0) { ! (void)close(data); data = -1; } if (closefunc != NULL && fout != NULL) (*closefunc)(fout); if (din) ! (void)fclose(din); if (bytes > 0) ptransfer(0); ! (void)signal(SIGINT, oldintr); ! (void)signal(SIGINFO, oldinti); } /* *************** *** 1115,1124 **** } if ((options & SO_DEBUG) && setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, ! sizeof (on)) < 0) warn("setsockopt (ignored)"); if (command("PASV") != COMPLETE) { ! printf("Passive mode refused.\n"); goto bad; } --- 1115,1124 ---- } if ((options & SO_DEBUG) && setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, ! sizeof(on)) < 0) warn("setsockopt (ignored)"); if (command("PASV") != COMPLETE) { ! puts("Passive mode refused."); goto bad; } *************** *** 1132,1139 **** if (sscanf(pasv, "%d,%d,%d,%d,%d,%d", &a0, &a1, &a2, &a3, &p0, &p1) != 6) { ! printf("Passive mode address scan failure. " ! "Shouldn't happen!\n"); goto bad; } --- 1132,1138 ---- if (sscanf(pasv, "%d,%d,%d,%d,%d,%d", &a0, &a1, &a2, &a3, &p0, &p1) != 6) { ! puts("Passive mode address scan failure. Shouldn't happen!"); goto bad; } *************** *** 1167,1173 **** if (sendport) data_addr.sin_port = 0; /* let system pick one */ if (data != -1) ! (void) close(data); data = socket(AF_INET, SOCK_STREAM, 0); if (data < 0) { warn("socket"); --- 1166,1172 ---- if (sendport) data_addr.sin_port = 0; /* let system pick one */ if (data != -1) ! (void)close(data); data = socket(AF_INET, SOCK_STREAM, 0); if (data < 0) { warn("socket"); *************** *** 1177,1195 **** } if (!sendport) if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, (char *)&on, ! sizeof (on)) < 0) { warn("setsockopt (reuse address)"); goto bad; } ! if (bind(data, (struct sockaddr *)&data_addr, sizeof (data_addr)) < 0) { warn("bind"); goto bad; } if (options & SO_DEBUG && setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, ! sizeof (on)) < 0) warn("setsockopt (ignored)"); ! len = sizeof (data_addr); if (getsockname(data, (struct sockaddr *)&data_addr, &len) < 0) { warn("getsockname"); goto bad; --- 1176,1194 ---- } if (!sendport) if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, (char *)&on, ! sizeof(on)) < 0) { warn("setsockopt (reuse address)"); goto bad; } ! if (bind(data, (struct sockaddr *)&data_addr, sizeof(data_addr)) < 0) { warn("bind"); goto bad; } if (options & SO_DEBUG && setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, ! sizeof(on)) < 0) warn("setsockopt (ignored)"); ! len = sizeof(data_addr); if (getsockname(data, (struct sockaddr *)&data_addr, &len) < 0) { warn("getsockname"); goto bad; *************** *** 1220,1226 **** #endif return (0); bad: ! (void) close(data), data = -1; if (tmpno) sendport = 1; return (1); --- 1219,1225 ---- #endif return (0); bad: ! (void)close(data), data = -1; if (tmpno) sendport = 1; return (1); *************** *** 1231,1237 **** const char *lmode; { struct sockaddr_in from; ! int s, fromlen = sizeof (from), tos; if (passivemode) return (fdopen(data, lmode)); --- 1230,1236 ---- const char *lmode; { struct sockaddr_in from; ! int s, fromlen = sizeof(from), tos; if (passivemode) return (fdopen(data, lmode)); *************** *** 1239,1248 **** s = accept(data, (struct sockaddr *) &from, &fromlen); if (s < 0) { warn("accept"); ! (void) close(data), data = -1; return (NULL); } ! (void) close(data); data = s; #ifdef IP_TOS tos = IPTOS_THROUGHPUT; --- 1238,1247 ---- s = accept(data, (struct sockaddr *) &from, &fromlen); if (s < 0) { warn("accept"); ! (void)close(data), data = -1; return (NULL); } ! (void)close(data); data = s; #ifdef IP_TOS tos = IPTOS_THROUGHPUT; *************** *** 1314,1323 **** ip->connect = connected; connected = op->connect; if (hostname) { ! (void) strncpy(ip->name, hostname, sizeof(ip->name) - 1); ! ip->name[strlen(ip->name)] = '\0'; } else ! ip->name[0] = 0; hostname = op->name; ip->hctl = hisctladdr; hisctladdr = op->hctl; --- 1313,1322 ---- ip->connect = connected; connected = op->connect; if (hostname) { ! (void)strncpy(ip->name, hostname, sizeof(ip->name) - 1); ! ip->name[sizeof(ip->name) - 1] = '\0'; } else ! ip->name[0] = '\0'; hostname = op->name; ip->hctl = hisctladdr; hisctladdr = op->hctl; *************** *** 1341,1361 **** mcase = op->mcse; ip->ntflg = ntflag; ntflag = op->ntflg; ! (void) strncpy(ip->nti, ntin, 16); ! (ip->nti)[strlen(ip->nti)] = '\0'; ! (void) strcpy(ntin, op->nti); ! (void) strncpy(ip->nto, ntout, 16); ! (ip->nto)[strlen(ip->nto)] = '\0'; ! (void) strcpy(ntout, op->nto); ip->mapflg = mapflag; mapflag = op->mapflg; ! (void) strncpy(ip->mi, mapin, MAXPATHLEN - 1); ! (ip->mi)[strlen(ip->mi)] = '\0'; ! (void) strcpy(mapin, op->mi); ! (void) strncpy(ip->mo, mapout, MAXPATHLEN - 1); ! (ip->mo)[strlen(ip->mo)] = '\0'; ! (void) strcpy(mapout, op->mo); ! (void) signal(SIGINT, oldintr); if (abrtflag) { abrtflag = 0; (*oldintr)(SIGINT); --- 1340,1360 ---- mcase = op->mcse; ip->ntflg = ntflag; ntflag = op->ntflg; ! (void)strncpy(ip->nti, ntin, sizeof(ip->nti) - 1); ! (ip->nti)[sizeof(ip->nti) - 1] = '\0'; ! (void)strcpy(ntin, op->nti); ! (void)strncpy(ip->nto, ntout, sizeof(ip->nto) - 1); ! (ip->nto)[sizeof(ip->nto) - 1] = '\0'; ! (void)strcpy(ntout, op->nto); ip->mapflg = mapflag; mapflag = op->mapflg; ! (void)strncpy(ip->mi, mapin, sizeof(ip->mi) - 1); ! (ip->mi)[sizeof(ip->mi) - 1] = '\0'; ! (void)strcpy(mapin, op->mi); ! (void)strncpy(ip->mo, mapout, sizeof(ip->mo) - 1); ! (ip->mo)[sizeof(ip->mo) - 1] = '\0'; ! (void)strcpy(mapout, op->mo); ! (void)signal(SIGINT, oldintr); if (abrtflag) { abrtflag = 0; (*oldintr)(SIGINT); *************** *** 1367,1374 **** { alarmtimer(0); ! printf("\n"); ! (void) fflush(stdout); ptabflg++; mflag = 0; abrtflag = 0; --- 1366,1373 ---- { alarmtimer(0); ! putchar('\n'); ! (void)fflush(stdout); ptabflg++; mflag = 0; abrtflag = 0; *************** *** 1397,1409 **** if (curtype != prox_type) changetype(prox_type, 1); if (command("PASV") != COMPLETE) { ! printf("proxy server does not support third party " ! "transfers.\n"); return; } pswitch(0); if (!connected) { ! printf("No primary connection\n"); pswitch(1); code = -1; return; --- 1396,1407 ---- if (curtype != prox_type) changetype(prox_type, 1); if (command("PASV") != COMPLETE) { ! puts("proxy server does not support third party transfers."); return; } pswitch(0); if (!connected) { ! puts("No primary connection"); pswitch(1); code = -1; return; *************** *** 1418,1424 **** goto abort; oldintr = signal(SIGINT, abortpt); if (command("%s %s", cmd, remote) != PRELIM) { ! (void) signal(SIGINT, oldintr); pswitch(1); return; } --- 1416,1422 ---- goto abort; oldintr = signal(SIGINT, abortpt); if (command("%s %s", cmd, remote) != PRELIM) { ! (void)signal(SIGINT, oldintr); pswitch(1); return; } *************** *** 1428,1443 **** if (command("%s %s", cmd2, local) != PRELIM) goto abort; ptflag++; ! (void) getreply(0); pswitch(0); ! (void) getreply(0); ! (void) signal(SIGINT, oldintr); pswitch(1); ptflag = 0; printf("local: %s remote: %s\n", local, remote); return; abort: ! (void) signal(SIGINT, SIG_IGN); ptflag = 0; if (strcmp(cmd, "RETR") && !proxy) pswitch(1); --- 1426,1441 ---- if (command("%s %s", cmd2, local) != PRELIM) goto abort; ptflag++; ! (void)getreply(0); pswitch(0); ! (void)getreply(0); ! (void)signal(SIGINT, oldintr); pswitch(1); ptflag = 0; printf("local: %s remote: %s\n", local, remote); return; abort: ! (void)signal(SIGINT, SIG_IGN); ptflag = 0; if (strcmp(cmd, "RETR") && !proxy) pswitch(1); *************** *** 1452,1458 **** pswitch(1); if (ptabflg) code = -1; ! (void) signal(SIGINT, oldintr); return; } if (cpend) --- 1450,1456 ---- pswitch(1); if (ptabflg) code = -1; ! (void)signal(SIGINT, oldintr); return; } if (cpend) *************** *** 1466,1472 **** pswitch(1); if (ptabflg) code = -1; ! (void) signal(SIGINT, oldintr); return; } } --- 1464,1470 ---- pswitch(1); if (ptabflg) code = -1; ! (void)signal(SIGINT, oldintr); return; } } *************** *** 1484,1498 **** code = -1; lostpeer(); } ! (void) getreply(0); ! (void) getreply(0); } if (proxy) pswitch(0); pswitch(1); if (ptabflg) code = -1; ! (void) signal(SIGINT, oldintr); } void --- 1482,1496 ---- code = -1; lostpeer(); } ! (void)getreply(0); ! (void)getreply(0); } if (proxy) pswitch(0); pswitch(1); if (ptabflg) code = -1; ! (void)signal(SIGINT, oldintr); } void *************** *** 1512,1518 **** lostpeer(); } else if (nfnd) { ! (void) getreply(0); } } } --- 1510,1516 ---- lostpeer(); } else if (nfnd) { ! (void)getreply(0); } } } *************** *** 1535,1546 **** warn("local: %s", local); return ((char *) 0); } ! (void) strcpy(new, local); cp = new + strlen(new); *cp++ = '.'; while (!d) { if (++count == 100) { ! printf("runique: can't find unique file name.\n"); return ((char *) 0); } *cp++ = ext; --- 1533,1544 ---- warn("local: %s", local); return ((char *) 0); } ! (void)strcpy(new, local); cp = new + strlen(new); *cp++ = '.'; while (!d) { if (++count == 100) { ! puts("runique: can't find unique file name."); return ((char *) 0); } *cp++ = ext; *************** *** 1579,1585 **** if (send(fileno(cout), buf, 3, MSG_OOB) != 3) warn("abort"); fprintf(cout, "%cABOR\r\n", DM); ! (void) fflush(cout); FD_ZERO(&mask); FD_SET(fileno(cin), &mask); if (din) { --- 1577,1583 ---- if (send(fileno(cout), buf, 3, MSG_OOB) != 3) warn("abort"); fprintf(cout, "%cABOR\r\n", DM); ! (void)fflush(cout); FD_ZERO(&mask); FD_SET(fileno(cin), &mask); if (din) { *************** *** 1599,1605 **** } if (getreply(0) == ERROR && code == 552) { /* 552 needed for nic style abort */ ! (void) getreply(0); } ! (void) getreply(0); } --- 1597,1603 ---- } if (getreply(0) == ERROR && code == 552) { /* 552 needed for nic style abort */ ! (void)getreply(0); } ! (void)getreply(0); }