On Sat, Sep 23, 2023 at 01:23:34PM +0200, Theo Buehler wrote: > This is a second chunk split out of the diff mentioned in my previous > mail. It factors the parsing of ASIdentifiers and IPAddrBlocks out of > sbgp_assysnum() and sbgp_ipaddrblk() and makes the latter only extract > the info from the X509_EXTENSION. This should not change anything, but > the logic is a bit tricky. > > We could initialize *as and *asz, as well as *ips and *ipsz to NULL/0, > at the top of the two new sbgp_parse_*.
It looks inded like nthing is changed. The thing I dislike a bit is how **as and *asz are updated inside the sbgp_parse_* functions. There is return 0 before and after the calloc / recallocarray calls and so it depends a lot on the caller to be careful here. The code right now is ok. One minor nit though: > Index: cert.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rpki-client/cert.c,v > retrieving revision 1.115 > diff -u -p -r1.115 cert.c > --- cert.c 12 Sep 2023 09:33:30 -0000 1.115 > +++ cert.c 23 Sep 2023 11:03:48 -0000 > +/* > + * Parse RFC 6487 4.8.11 X509v3 extension, with syntax documented in RFC > + * 3779 starting in section 3.2. > + * Returns zero on failure, non-zero on success. > + */ > +static int > +sbgp_assysnum(struct parse *p, X509_EXTENSION *ext) > +{ > + ASIdentifiers *asidentifiers = NULL; > + int rc = 0; > + > + if (!X509_EXTENSION_get_critical(ext)) { > + warnx("%s: RFC 6487 section 4.8.11: autonomousSysNum: " > + "extension not critical", p->fn); > + goto out; > + } > + > + if ((asidentifiers = X509V3_EXT_d2i(ext)) == NULL) { > + warnx("%s: RFC 6487 section 4.8.11: autonomousSysNum: " > + "failed extension parse", p->fn); > + goto out; > + } > + > + if (!sbgp_parse_assysnum(p->fn, asidentifiers, &p->res->as, > &p->res->asz)) This line is over 80 chars. Apart from that OK. -- :wq Claudio