summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2019-01-17 13:32:24 +1100
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2019-02-01 11:07:50 +1100
commit28d0d7035ee3099935ef264db40a86142c098ec5 (patch)
tree7bdc08eb8c6e3e1ccbf41c1f1616a9f6bdd33dcd /lib
parent89cde533356d47b34a80679602c3900572b2dca6 (diff)
downloadtalos-petitboot-28d0d7035ee3099935ef264db40a86142c098ec5.zip
talos-petitboot-28d0d7035ee3099935ef264db40a86142c098ec5.tar.gz
lib/url: Include port in pb_url_to_string()v1.10.1
And include a pxe-parser test which uses a port in the path prefix to exercise this. This could cause PXE discovery failures if parameters such as pathprefix included a port in the URL. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/url/url.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/url/url.c b/lib/url/url.c
index 44e9ac4..b74018d 100644
--- a/lib/url/url.c
+++ b/lib/url/url.c
@@ -265,14 +265,21 @@ int addr_scheme(const char *address)
char *pb_url_to_string(struct pb_url *url)
{
const struct pb_scheme_info *scheme = pb_url_scheme_info(url->scheme);
+ char *str, *port;
assert(scheme);
+ port = url->port ? talloc_asprintf(url, ":%s", url->port) : NULL;
+
if (scheme->has_host && addr_scheme(url->host) == AF_INET6)
- return talloc_asprintf(url, "%s://[%s]%s", scheme->str,
- url->host, url->path);
+ str = talloc_asprintf(url, "%s://[%s]%s%s", scheme->str,
+ url->host, port ?: "", url->path);
else
- return talloc_asprintf(url, "%s://%s%s", scheme->str,
- scheme->has_host ? url->host : "", url->path);
+ str = talloc_asprintf(url, "%s://%s%s%s", scheme->str,
+ scheme->has_host ? url->host : "",
+ port ?: "", url->path);
+
+ talloc_free(port);
+ return str;
}
static void pb_url_update_full(struct pb_url *url)
OpenPOWER on IntegriCloud