commit b45edeef75e1ab2ad82158c4b8a29cdf6fe0d80a
parent d7941965df27f71a00e76e5e278446c7b9a2cdc9
Author: Nihal Jere <nihal@nihaljere.xyz>
Date: Wed, 17 Feb 2021 23:45:57 -0600
http.c: make url an array, allowing modification, allowing redirection
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/http.c b/http.c
@@ -33,7 +33,7 @@ static time_t config_timeout = 0;
/* parsed uri */
static struct uri u;
/* raw command-line argument */
-static char *url;
+static char url[2048];
/* TLS config */
static struct tls_config *tls_config;
/* where to write to */
@@ -380,7 +380,11 @@ http_fetch(char *loc, char *path)
{
int statuscode;
- url = loc;
+ if (strlen(loc) > 2047)
+ die("%s: url too long: %s", __func__, url);
+
+ strcpy(url, loc);
+
if (parseuri(url, &u) == -1)
die("invalid url: %s", url);