In the roa parser the handling of maxlen is overly complex. Just set maxlen to addr.prefixlen before parsing the maxlength option. If present it will override maxlen with the new value and with that the ternary confusion at the end can be removed.
-- :wq Claudio Index: roa.c =================================================================== RCS file: /cvs/src/usr.sbin/rpki-client/roa.c,v retrieving revision 1.33 diff -u -p -r1.33 roa.c --- roa.c 3 Dec 2021 12:56:19 -0000 1.33 +++ roa.c 21 Dec 2021 18:09:27 -0000 @@ -50,7 +50,7 @@ roa_parse_addr(const ASN1_OCTET_STRING * size_t dsz = os->length; int rc = 0; const ASN1_TYPE *t; - const ASN1_INTEGER *maxlength = NULL; + const ASN1_INTEGER *maxlength; long maxlen; struct ip_addr addr; struct roa_ip *res; @@ -83,6 +83,7 @@ roa_parse_addr(const ASN1_OCTET_STRING * "invalid IP address", p->fn); goto out; } + maxlen = addr.prefixlen; if (sk_ASN1_TYPE_num(seq) == 2) { t = sk_ASN1_TYPE_value(seq, 1); @@ -115,7 +116,7 @@ roa_parse_addr(const ASN1_OCTET_STRING * res->addr = addr; res->afi = afi; - res->maxlength = (maxlength == NULL) ? addr.prefixlen : maxlen; + res->maxlength = maxlen; ip_roa_compose_ranges(res); rc = 1;