diff options
author | Alexander Hall <halex@cvs.openbsd.org> | 2014-07-11 18:19:46 +0000 |
---|---|---|
committer | Alexander Hall <halex@cvs.openbsd.org> | 2014-07-11 18:19:46 +0000 |
commit | 6dd3a26fa54529a717bcf49dddd59e534fde1d12 (patch) | |
tree | a563e3d15d042723fe44e7479f85b429156bbe5e /usr.bin/ftp | |
parent | 06a6b28789c06946d1533b2604d9cc6b1057b300 (diff) |
simplify and slightly tweak user agent handling
ok lteo@
Diffstat (limited to 'usr.bin/ftp')
-rw-r--r-- | usr.bin/ftp/fetch.c | 15 | ||||
-rw-r--r-- | usr.bin/ftp/main.c | 12 |
2 files changed, 7 insertions, 20 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index 5ac2231d1c0..0c07aa07abc 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.124 2014/07/11 03:31:52 lteo Exp $ */ +/* $OpenBSD: fetch.c,v 1.125 2014/07/11 18:19:45 halex Exp $ */ /* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */ /*- @@ -1284,9 +1284,6 @@ auto_fetch(int argc, char *argv[], char *outfile) char *cp, *url, *host, *dir, *file, *portnum; char *username, *pass, *pathstart; char *ftpproxy, *httpproxy; -#ifndef SMALL - char *uagent = NULL; -#endif /* !SMALL */ int rval, xargc; volatile int argpos; int dirhasglob, filehasglob, oautologin; @@ -1307,13 +1304,6 @@ auto_fetch(int argc, char *argv[], char *outfile) if ((httpproxy = getenv(HTTP_PROXY)) != NULL && *httpproxy == '\0') httpproxy = NULL; - if (httpuseragent == NULL) - httpuseragent = HTTP_USER_AGENT; -#ifndef SMALL - else - uagent = httpuseragent; -#endif /* !SMALL */ - /* * Loop through as long as there's files to fetch. */ @@ -1590,9 +1580,6 @@ bad_ftp_url: } if (connected && rval != -1) disconnect(0, NULL); -#ifndef SMALL - free(uagent); -#endif /* !SMALL */ return (rval); } diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c index 5c3c2e858a3..e67b75b1859 100644 --- a/usr.bin/ftp/main.c +++ b/usr.bin/ftp/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.88 2014/07/11 03:31:52 lteo Exp $ */ +/* $OpenBSD: main.c,v 1.89 2014/07/11 18:19:45 halex Exp $ */ /* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */ /* @@ -362,19 +362,17 @@ main(volatile int argc, char *argv[]) trace = 1; break; - case 'U': #ifndef SMALL - if (httpuseragent) - errx(1, "User-Agent was already defined"); - /* Ensure that User-Agent value is in a single line. */ + case 'U': + free (httpuseragent); if (strcspn(optarg, "\r\n") != strlen(optarg)) errx(1, "Invalid User-Agent: %s.", optarg); if (asprintf(&httpuseragent, "User-Agent: %s", optarg) == -1) errx(1, "Can't allocate memory for HTTP(S) " "User-Agent"); -#endif /* !SMALL */ break; +#endif /* !SMALL */ case 'v': verbose = 1; @@ -394,6 +392,8 @@ main(volatile int argc, char *argv[]) #ifndef SMALL cookie_load(); #endif /* !SMALL */ + if (httpuseragent == NULL) + httpuseragent = HTTP_USER_AGENT; cpend = 0; /* no pending replies */ proxy = 0; /* proxy not active */ |