Copy port to proxyport since the sting may point into memory that is
authorclaudio <claudio@openbsd.org>
Tue, 18 Oct 2022 14:03:39 +0000 (14:03 +0000)
committerclaudio <claudio@openbsd.org>
Tue, 18 Oct 2022 14:03:39 +0000 (14:03 +0000)
freed.

Should fix https://github.com/rpki-client/rpki-client-portable/issues/74
Reported by Ben Castricum
OK tb@

usr.sbin/rpki-client/http.c

index eef65af..f89a10f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: http.c,v 1.69 2022/09/20 08:53:27 claudio Exp $ */
+/*     $OpenBSD: http.c,v 1.70 2022/10/18 14:03:39 claudio Exp $ */
 /*
  * Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
  * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@@ -408,7 +408,8 @@ proxy_parse_uri(char *uri)
 
        if ((proxy.proxyhost = strdup(host)) == NULL)
                err(1, NULL);
-       proxy.proxyport = port;
+       if ((proxy.proxyport = strdup(port)) == NULL)
+               err(1, NULL);
        proxy.proxyauth = cookie;
 
        free(fullhost);