=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/fetch.c,v retrieving revision 1.68 retrieving revision 1.69 diff -c -r1.68 -r1.69 *** src/usr.bin/ftp/fetch.c 2006/07/07 12:00:25 1.68 --- src/usr.bin/ftp/fetch.c 2006/09/25 10:18:39 1.69 *************** *** 1,4 **** ! /* $OpenBSD: fetch.c,v 1.68 2006/07/07 12:00:25 ray Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- --- 1,4 ---- ! /* $OpenBSD: fetch.c,v 1.69 2006/09/25 10:18:39 jsg Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- *************** *** 38,44 **** */ #if !defined(lint) && !defined(SMALL) ! static const char rcsid[] = "$OpenBSD: fetch.c,v 1.68 2006/07/07 12:00:25 ray Exp $"; #endif /* not lint and not SMALL */ /* --- 38,44 ---- */ #if !defined(lint) && !defined(SMALL) ! static const char rcsid[] = "$OpenBSD: fetch.c,v 1.69 2006/09/25 10:18:39 jsg Exp $"; #endif /* not lint and not SMALL */ /* *************** *** 118,124 **** static int url_get(const char *origline, const char *proxyenv, const char *outfile) { ! char pbuf[NI_MAXSERV], hbuf[NI_MAXHOST], *cp, *portnum, *path; char *hosttail, *cause = "unknown", *newline, *host, *port, *buf = NULL; int error, i, isftpurl = 0, isfileurl = 0, isredirect = 0, rval = -1; struct addrinfo hints, *res0, *res; --- 118,124 ---- static int url_get(const char *origline, const char *proxyenv, const char *outfile) { ! char pbuf[NI_MAXSERV], hbuf[NI_MAXHOST], *cp, *portnum, *path, ststr[4]; char *hosttail, *cause = "unknown", *newline, *host, *port, *buf = NULL; int error, i, isftpurl = 0, isfileurl = 0, isredirect = 0, rval = -1; struct addrinfo hints, *res0, *res; *************** *** 132,138 **** size_t len, wlen; #ifndef SMALL char *sslpath = NULL, *sslhost = NULL; ! int ishttpsurl = 0; SSL_CTX *ssl_ctx = NULL; #endif SSL *ssl = NULL; --- 132,138 ---- size_t len, wlen; #ifndef SMALL char *sslpath = NULL, *sslhost = NULL; ! int ishttpsurl = 0, status; SSL_CTX *ssl_ctx = NULL; #endif SSL *ssl = NULL; *************** *** 486,498 **** goto improper; else cp++; ! if (strncmp(cp, "301", 3) == 0 || strncmp(cp, "302", 3) == 0) { isredirect++; if (redirect_loop++ > 10) { warnx("Too many redirections requested"); goto cleanup_url_get; } ! } else if (strncmp(cp, "200", 3)) { warnx("Error retrieving file: %s", cp); goto cleanup_url_get; } --- 486,513 ---- goto improper; else cp++; ! ! strlcpy(ststr, cp, sizeof(ststr)); ! status = strtonum(ststr, 200, 307, &errstr); ! if (errstr) { ! warnx("Error retrieving file: %s", cp); ! goto cleanup_url_get; ! } ! ! switch (status) { ! case 200: /* OK */ ! break; ! case 301: /* Moved Permanently */ ! case 302: /* Found */ ! case 303: /* See Other */ ! case 307: /* Temporary Redirect */ isredirect++; if (redirect_loop++ > 10) { warnx("Too many redirections requested"); goto cleanup_url_get; } ! break; ! default: warnx("Error retrieving file: %s", cp); goto cleanup_url_get; }