summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-06-01 22:42:12 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-06-01 22:42:12 +0000
commitfff1c1e24f6f58e55881a74c755dfe1e500b1ad0 (patch)
tree0cc8bfedf8c164ea5ccfc5817efc22ca9d57ecdf
parent53f49de83a616883ff7ef624e0be1700d8f286a5 (diff)
Remove two unnecessary strlen() calls. Also, check if asprintf
returns -1 instead of checking if connstr == NULL. OK beck@, moritz@
-rw-r--r--usr.bin/ftp/fetch.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c
index aac34623fbc..4b227dcde9a 100644
--- a/usr.bin/ftp/fetch.c
+++ b/usr.bin/ftp/fetch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fetch.c,v 1.65 2006/05/25 03:48:23 ray Exp $ */
+/* $OpenBSD: fetch.c,v 1.66 2006/06/01 22:42:11 ray Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */
/*-
@@ -38,7 +38,7 @@
*/
#if !defined(lint) && !defined(SMALL)
-static const char rcsid[] = "$OpenBSD: fetch.c,v 1.65 2006/05/25 03:48:23 ray Exp $";
+static const char rcsid[] = "$OpenBSD: fetch.c,v 1.66 2006/06/01 22:42:11 ray Exp $";
#endif /* not lint and not SMALL */
/*
@@ -1129,6 +1129,7 @@ SSL_readline(SSL *ssl, size_t *lenp)
int
proxy_connect(int socket, char *host)
{
+ int l;
char buf[1024];
char *connstr, *hosttail, *port;
@@ -1147,10 +1148,10 @@ proxy_connect(int socket, char *host)
if (debug)
printf("CONNECT %s:%s HTTP/1.1\n\n", host, port);
- asprintf(&connstr, "CONNECT %s:%s HTTP/1.1\n\n", host, port);
- if (!connstr)
+ l = asprintf(&connstr, "CONNECT %s:%s HTTP/1.1\n\n", host, port);
+ if (l == -1)
errx(1, "Could not allocate memory to assemble connect string!");
- if (write(socket, connstr, strlen(connstr)) != strlen(connstr))
+ if (write(socket, connstr, l) != l)
errx(1, "Could not send connect string: %s", strerror(errno));
read(socket, &buf, sizeof(buf)); /* only proxy header XXX: error handling? */
return(200);