summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/url.c
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-12-22 17:02:09 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-12-22 17:02:09 +0000
commit4b01e5255a3886df26fd51e78c3272463ae0e9e3 (patch)
treef706cf4a5c7e5138885d71af19adb26c1ee85ee6 /mdk-stage1/url.c
parentb0f87236c9e3fdfe75732701838df534fba3d423 (diff)
downloaddrakx-4b01e5255a3886df26fd51e78c3272463ae0e9e3.tar
drakx-4b01e5255a3886df26fd51e78c3272463ae0e9e3.tar.gz
drakx-4b01e5255a3886df26fd51e78c3272463ae0e9e3.tar.bz2
drakx-4b01e5255a3886df26fd51e78c3272463ae0e9e3.tar.xz
drakx-4b01e5255a3886df26fd51e78c3272463ae0e9e3.zip
try to use asprintf a bit (hope it doesn't segfault too much)
Diffstat (limited to 'mdk-stage1/url.c')
-rw-r--r--mdk-stage1/url.c14
1 files changed, 3 insertions, 11 deletions
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));