From 54b5b17a38eefb16036e06d9f25ff0e73eb1b948 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Thu, 24 Jul 1997 14:22:22 +0000 Subject: no content-length is OK; cato@ulysses.df.lth.se --- usr.bin/ftp/fetch.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index 1a843c31cc8..a02399eedab 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fetch.c,v 1.12 1997/05/19 05:36:56 millert Exp $ */ +/* $OpenBSD: fetch.c,v 1.13 1997/07/24 14:22:21 deraadt Exp $ */ /* $NetBSD: fetch.c,v 1.8 1997/04/21 18:45:47 lukem Exp $ */ /*- @@ -38,7 +38,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: fetch.c,v 1.12 1997/05/19 05:36:56 millert Exp $"; +static char rcsid[] = "$OpenBSD: fetch.c,v 1.13 1997/07/24 14:22:21 deraadt Exp $"; #endif /* not lint */ /* @@ -203,7 +203,7 @@ url_get(line, proxyenv, fd) path); else fprintf(ttyout, "Requesting %s (via %s)\n", line, proxyenv); - snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\n\n", + snprintf(buf, sizeof(buf), "GET %s%s HTTP/1.0\r\n\r\n", proxy ? "" : "/", path); buflen = strlen(buf); if (write(s, buf, buflen) < buflen) { @@ -253,17 +253,18 @@ url_get(line, proxyenv, fd) strncasecmp(cp, CONTENTLEN, sizeof(CONTENTLEN) - 1) == 0) break; } - if (*cp == '\0') - goto improper; - cp += sizeof(CONTENTLEN) - 1; - cp2 = strchr(cp, '\n'); - if (cp2 == NULL) - goto improper; - else - *cp2 = '\0'; - filesize = atoi(cp); - if (filesize < 1) - goto improper; + if (*cp != '\0') { + cp += sizeof(CONTENTLEN) - 1; + cp2 = strchr(cp, '\n'); + if (cp2 == NULL) + goto improper; + else + *cp2 = '\0'; + filesize = atoi(cp); + if (filesize < 1) + goto improper; + } else + filesize = -1; /* Open the output file. */ if (fd == -1) { -- cgit v1.2.3