Mageia Bugzilla – Attachment 12349 Details for
Bug 28367
Enable users to specify the mirror port in Installer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
Quick untested patch
0001-Support-a-port-in-HTTP-host.patch (text/plain), 2.20 KB, created by
Pascal Terjan
on 2021-02-17 22:46:28 CET
(
hide
)
Description:
Quick untested patch
Filename:
MIME Type:
Creator:
Pascal Terjan
Created:
2021-02-17 22:46:28 CET
Size:
2.20 KB
patch
obsolete
>From 4c6cf08af77fcb7459798cab835062081c39bfbd Mon Sep 17 00:00:00 2001 >From: Pascal Terjan <pterjan@mageia.org> >Date: Wed, 17 Feb 2021 21:44:18 +0000 >Subject: [PATCH] Support a port in HTTP host > >--- > mdk-stage1/url.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > >diff --git a/mdk-stage1/url.c b/mdk-stage1/url.c >index 3d2846649..14f1e25d6 100644 >--- a/mdk-stage1/url.c >+++ b/mdk-stage1/url.c >@@ -398,9 +398,10 @@ char *str_ftp_error(int error) > } > > >-static int _http_download_file(char * hostname, char * remotename, int * size, char * proxyprotocol, char * proxyname, char * proxyport, int recursion) >+static int _http_download_file(char * hostport, char * remotename, int * size, char * proxyprotocol, char * proxyname, char * proxyport, int recursion) > { > char * buf; >+ char * hostname = strdup(hostport); > char headers[4096]; > char * nextChar = headers; > int statusCode; >@@ -418,8 +419,15 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c > http_server_name = proxyname; > http_server_port = atoi(proxyport); > } else { >- http_server_name = hostname; >- http_server_port = 80; >+ char *port = strchr(hostname, ':'); >+ if (port) { >+ *port = '\0'; >+ http_server_name = hostname; >+ http_server_port = atoi(++port); >+ } else { >+ http_server_name = hostname; >+ http_server_port = 80; >+ } > } > > log_message("HTTP: connecting to server %s:%i (%s)", >@@ -430,6 +438,7 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c > > sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); > if (sock < 0) { >+ free(hostname); > return FTPERR_FAILED_CONNECT; > } > >@@ -439,6 +448,7 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c > > if (connect(sock, (struct sockaddr *) &destPort, sizeof(destPort))) { > close(sock); >+ free(hostname); > return FTPERR_FAILED_CONNECT; > } > >@@ -446,6 +456,7 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c > : asprintf_("GET %s HTTP/1.0\r\nHost: %s\r\n\r\n", remotename, hostname); > > write(sock, buf, strlen(buf)); >+ free(hostname); > > /* This is fun; read the response a character at a time until we: > >-- >2.30.0 >
From 4c6cf08af77fcb7459798cab835062081c39bfbd Mon Sep 17 00:00:00 2001 From: Pascal Terjan <pterjan@mageia.org> Date: Wed, 17 Feb 2021 21:44:18 +0000 Subject: [PATCH] Support a port in HTTP host --- mdk-stage1/url.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mdk-stage1/url.c b/mdk-stage1/url.c index 3d2846649..14f1e25d6 100644 --- a/mdk-stage1/url.c +++ b/mdk-stage1/url.c @@ -398,9 +398,10 @@ char *str_ftp_error(int error) } -static int _http_download_file(char * hostname, char * remotename, int * size, char * proxyprotocol, char * proxyname, char * proxyport, int recursion) +static int _http_download_file(char * hostport, char * remotename, int * size, char * proxyprotocol, char * proxyname, char * proxyport, int recursion) { char * buf; + char * hostname = strdup(hostport); char headers[4096]; char * nextChar = headers; int statusCode; @@ -418,8 +419,15 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c http_server_name = proxyname; http_server_port = atoi(proxyport); } else { - http_server_name = hostname; - http_server_port = 80; + char *port = strchr(hostname, ':'); + if (port) { + *port = '\0'; + http_server_name = hostname; + http_server_port = atoi(++port); + } else { + http_server_name = hostname; + http_server_port = 80; + } } log_message("HTTP: connecting to server %s:%i (%s)", @@ -430,6 +438,7 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if (sock < 0) { + free(hostname); return FTPERR_FAILED_CONNECT; } @@ -439,6 +448,7 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c if (connect(sock, (struct sockaddr *) &destPort, sizeof(destPort))) { close(sock); + free(hostname); return FTPERR_FAILED_CONNECT; } @@ -446,6 +456,7 @@ static int _http_download_file(char * hostname, char * remotename, int * size, c : asprintf_("GET %s HTTP/1.0\r\nHost: %s\r\n\r\n", remotename, hostname); write(sock, buf, strlen(buf)); + free(hostname); /* This is fun; read the response a character at a time until we: -- 2.30.0
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 28367
: 12349