Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
Re: rpki-client: use more *_PROTO_LEN
To:
Theo Buehler <tb@theobuehler.org>
Cc:
tech@openbsd.org
Date:
Thu, 14 Nov 2024 10:27:31 +0100

Download raw body.

Thread
On Thu, Nov 14, 2024 at 12:53:08AM +0100, Theo Buehler wrote:
> We added these constants and used them for str*cmp, but somehow we still
> end up skipping by hardcoded lengths, which seems weird.

OK claudio@
 
> Index: http.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/http.c,v
> diff -u -p -r1.87 http.c
> --- http.c	8 Sep 2024 07:23:36 -0000	1.87
> +++ http.c	13 Nov 2024 23:03:54 -0000
> @@ -415,7 +415,7 @@ proxy_parse_uri(char *uri)
>  	if (strncasecmp(uri, HTTP_PROTO, HTTP_PROTO_LEN) != 0)
>  		errx(1, "%s: http_proxy not using http schema", http_info(uri));
>  
> -	host = uri + 7;
> +	host = uri + HTTP_PROTO_LEN;
>  	if ((fullhost = strndup(host, strcspn(host, "/"))) == NULL)
>  		err(1, NULL);
>  
> @@ -483,7 +483,7 @@ http_parse_uri(char *uri, char **ohost, 
>  		warnx("%s: not using https schema", http_info(uri));
>  		return -1;
>  	}
> -	host = uri + 8;
> +	host = uri + HTTPS_PROTO_LEN;
>  	if ((path = strchr(host, '/')) == NULL) {
>  		warnx("%s: missing https path", http_info(uri));
>  		return -1;
> Index: main.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/main.c,v
> diff -u -p -r1.270 main.c
> --- main.c	13 Nov 2024 12:51:04 -0000	1.270
> +++ main.c	13 Nov 2024 23:04:08 -0000
> @@ -500,7 +500,7 @@ queue_add_from_cert(const struct cert *c
>  
>  	if (strncmp(cert->repo, RSYNC_PROTO, RSYNC_PROTO_LEN) != 0)
>  		errx(1, "unexpected protocol");
> -	host = cert->repo + 8;
> +	host = cert->repo + RSYNC_PROTO_LEN;
>  
>  	LIST_FOREACH(le, &skiplist, entry) {
>  		if (strncasecmp(host, le->fqdn, strcspn(host, "/")) == 0) {
> Index: rsync.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/rsync.c,v
> diff -u -p -r1.51 rsync.c
> --- rsync.c	20 Aug 2024 13:31:49 -0000	1.51
> +++ rsync.c	13 Nov 2024 23:46:25 -0000
> @@ -71,7 +71,7 @@ rsync_base_uri(const char *uri)
>  	}
>  
>  	/* Parse the non-zero-length hostname. */
> -	host = uri + 8;
> +	host = uri + RSYNC_PROTO_LEN;
>  
>  	if ((module = strchr(host, '/')) == NULL) {
>  		warnx("%s: missing rsync module", uri);
> 

-- 
:wq Claudio