Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
Re: rpki-client: small aspa weirdnesses
To:
Theo Buehler <tb@theobuehler.org>
Cc:
tech@openbsd.org
Date:
Fri, 14 Nov 2025 07:11:37 +0100

Download raw body.

Thread
On Fri, Nov 14, 2025 at 05:35:40AM +0100, Theo Buehler wrote:
> We don't need memset to set a uint32_t to zero. We can also use a better
> idiom to allocate the aspa->providers.
> 
> Index: aspa.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/rpki-client/aspa.c,v
> diff -u -p -r1.39 aspa.c
> --- aspa.c	25 Aug 2025 04:13:56 -0000	1.39
> +++ aspa.c	27 Aug 2025 07:37:40 -0000
> @@ -56,7 +56,6 @@ aspa_parse_providers(const char *fn, str
>      const STACK_OF(ASN1_INTEGER) *providers)
>  {
>  	const ASN1_INTEGER	*pa;
> -	uint32_t		 provider;
>  	size_t			 providersz, i;
>  
>  	if ((providersz = sk_ASN1_INTEGER_num(providers)) == 0) {
> @@ -70,14 +69,14 @@ aspa_parse_providers(const char *fn, str
>  		return 0;
>  	}
>  
> -	aspa->providers = calloc(providersz, sizeof(provider));
> +	aspa->providers = calloc(providersz, sizeof(aspa->providers[0]));
>  	if (aspa->providers == NULL)
>  		err(1, NULL);
>  
>  	for (i = 0; i < providersz; i++) {
> -		pa = sk_ASN1_INTEGER_value(providers, i);
> +		uint32_t provider = 0;
>  
> -		memset(&provider, 0, sizeof(provider));
> +		pa = sk_ASN1_INTEGER_value(providers, i);
>  
>  		if (!as_id_parse(pa, &provider)) {
>  			warnx("%s: ASPA: malformed ProviderAS", fn);
> 

Looks good to me.

-- 
:wq Claudio