summaryrefslogtreecommitdiffstats
path: root/usr.bin/fetch/ftp.c
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1997-02-05 19:59:18 +0000
committerwollman <wollman@FreeBSD.org>1997-02-05 19:59:18 +0000
commit37ca85c089f28bd04237b7fd363ad07b07994aac (patch)
tree3eb28344fec90f861cb268c3467fefc2a8aee72f /usr.bin/fetch/ftp.c
parentf061fa28f5ac3f93d633c36e904431dd425e25ba (diff)
downloadFreeBSD-src-37ca85c089f28bd04237b7fd363ad07b07994aac.zip
FreeBSD-src-37ca85c089f28bd04237b7fd363ad07b07994aac.tar.gz
Some bug-fixes, clean-ups, and one new feature:
- Fix the bug with URIs of the form ftp://host/filename. - Fix some more string-termination bugs in util.c. - Use safe_malloc() rather than testing the return value of regular malloc() in 15 places. - Implement HTTP authentication, for both servers and proxies. Currently only ``basic'' authentication is supported; This Is A Bug (but less of one tjhan nmot supporting any authentication). I think there is only one more feature which is required for full HTTP/1.1 support, which is Transfer-Encoding: chunked; this should not be toohard, but it isn't very important, either.
Diffstat (limited to 'usr.bin/fetch/ftp.c')
-rw-r--r--usr.bin/fetch/ftp.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/usr.bin/fetch/ftp.c b/usr.bin/fetch/ftp.c
index 34caeb0..0960b81 100644
--- a/usr.bin/fetch/ftp.c
+++ b/usr.bin/fetch/ftp.c
@@ -26,7 +26,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: ftp.c,v 1.1 1997/01/30 21:43:40 wollman Exp $
*/
#include <sys/types.h>
@@ -114,9 +114,7 @@ ftp_parse(struct fetch_state *fs, const char *uri)
p = slash + 1;
- ftps = malloc(sizeof *ftps);
- if (ftps == 0)
- err(EX_OSERR, "malloc");
+ ftps = safe_malloc(sizeof *ftps);
/*
* Now, we have a copy of the hostname in hostname, the specified port
@@ -146,7 +144,7 @@ ftp_parse(struct fetch_state *fs, const char *uri)
if (fs->fs_outputfile == 0) {
slash = strrchr(p, '/');
- fs->fs_outputfile = slash + 1;
+ fs->fs_outputfile = slash ? slash + 1 : p;
}
ftps->ftp_password = getenv("FTP_PASSWORD");
@@ -161,9 +159,7 @@ ftp_parse(struct fetch_state *fs, const char *uri)
if (logname == 0)
logname = "root";
gethostname(localhost, sizeof localhost);
- pw = malloc(strlen(logname) + 1 + strlen(localhost) + 1);
- if (pw == 0)
- err(EX_OSERR, "malloc");
+ pw = safe_malloc(strlen(logname) + 1 + strlen(localhost) + 1);
strcpy(pw, logname);
strcat(pw, "@");
strcat(pw, localhost);
@@ -242,10 +238,9 @@ ftp_proxy_parse(struct fetch_state *fs, const char *uri)
ftps->ftp_port = portno;
user = ftps->ftp_user ? ftps->ftp_user : "anonymous";
- newpass = malloc(strlen(ftps->ftp_user ? ftps->ftp_user : "anonymous")
- + 1 + strlen(ftps->ftp_hostname) + 1);
- if (newpass == 0)
- err(EX_OSERR, "malloc");
+ newpass = safe_malloc(strlen(ftps->ftp_user
+ ? ftps->ftp_user : "anonymous")
+ + 1 + strlen(ftps->ftp_hostname) + 1);
strcpy(newpass, user);
strcat(newpass, "@");
OpenPOWER on IntegriCloud