Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: acme-client(1): port numbers in API urls
To:
tech <tech@openbsd.org>
Date:
Sun, 8 Jun 2025 19:26:09 +0200

Download raw body.

Thread
On Sun, Jun 08, 2025 at 03:07:43PM +0200, Florian Obser wrote:
> This is needed to test against the "pebble" let's encrypt test server.

fine with it in principle, but

> +	/* extract port */
> +	if ((ep = strchr(url, ':')) != NULL) {
> +		const char *errstr;
> +		char *p = strdup(ep + 1);

I would not use strdup() here. Setting p = ep + 1 or doing a direct
strtonum(ep + 1, ...) would simplify this.

> +		if (p == NULL) {
> +			warn("strdup");
> +			free(url);

need to free *path (I'd also NULL it out), as the callers will leak it.

> +			return NULL;
> +		}
> +		*ep = '\0';
> +		*port = strtonum(p, 1, USHRT_MAX, &errstr);
> +		if (errstr != NULL) {
> +			warn("port is %s: %s", errstr, p);
> +			free(url);
> +			free(p);

same here re *path

> +			return NULL;
> +		}
> +		free(p);
> +		

this empty line (with two tabs) should not be here imo

> +	}
> +
>  	return url;
>  }
>  
> 
> -- 
> In my defence, I have been left unsupervised.
>