From 4b01e5255a3886df26fd51e78c3272463ae0e9e3 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Mon, 22 Dec 2003 17:02:09 +0000 Subject: try to use asprintf a bit (hope it doesn't segfault too much) --- mdk-stage1/url.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'mdk-stage1/url.c') diff --git a/mdk-stage1/url.c b/mdk-stage1/url.c index 4d8a3f5c9..d3b03f942 100644 --- a/mdk-stage1/url.c +++ b/mdk-stage1/url.c @@ -171,7 +171,6 @@ int ftp_open_connection(char * host, char * name, char * password, char * proxy) int sock; struct in_addr serverAddress; struct sockaddr_in destPort; - char * buf; int rc; int port = 21; @@ -181,9 +180,7 @@ int ftp_open_connection(char * host, char * name, char * password, char * proxy) } if (strcmp(proxy, "")) { - buf = alloca(strlen(name) + strlen(host) + 5); - sprintf(buf, "%s@%s", name, host); - name = buf; + name = asprintf_("%s@%s", name, host); host = proxy; } @@ -437,13 +434,8 @@ int http_download_file(char * hostname, char * remotename, int * size, char * pr return FTPERR_FAILED_CONNECT; } - if (proxyprotocol) { - buf = alloca(4 + strlen(proxyprotocol) + 3 + strlen(hostname) + strlen(remotename) + 11 + 6 + strlen(hostname) + 4 + 1); - sprintf(buf, "GET %s://%s%s HTTP/0.9\r\nHost: %s\r\n\r\n", proxyprotocol, hostname, remotename, hostname); - } else { - buf = alloca(4 + strlen(remotename) + 11 + 6 + strlen(hostname) + 4 + 1); - sprintf(buf, "GET %s HTTP/0.9\r\nHost: %s\r\n\r\n", remotename, hostname); - } + buf = proxyprotocol ? asprintf_("GET %s://%s%s HTTP/0.9\r\nHost: %s\r\n\r\n", proxyprotocol, hostname, remotename, hostname) + : asprintf_("GET %s HTTP/0.9\r\nHost: %s\r\n\r\n", remotename, hostname); write(sock, buf, strlen(buf)); -- cgit v1.2.1