diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2020-10-24 08:09:40 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2020-10-24 08:09:40 +0000 |
commit | b0440494eb2be94ea45c38ec1a187b770f36882b (patch) | |
tree | 655a62b7d5238b247bb985274a4c5c2f16e50061 /usr.sbin/rpki-client | |
parent | 1c21489e104e9c2a058040b29e2c8c5242d140f2 (diff) |
Refactor sbgp_sia_resource_mft() similar to sbgp_sia_resource_notify().
Instead of rsync_uri_parse() check the start of the uri for rsync:// and
also check that the uri ends in .mft.
OK tb@
Diffstat (limited to 'usr.sbin/rpki-client')
-rw-r--r-- | usr.sbin/rpki-client/cert.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/usr.sbin/rpki-client/cert.c b/usr.sbin/rpki-client/cert.c index 1f9eb524a3e..4c400c9495f 100644 --- a/usr.sbin/rpki-client/cert.c +++ b/usr.sbin/rpki-client/cert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cert.c,v 1.18 2020/09/12 15:46:48 claudio Exp $ */ +/* $OpenBSD: cert.c,v 1.19 2020/10/24 08:09:39 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -149,7 +149,8 @@ sbgp_sia_resource_notify(struct parse *p, /* Make sure it's a https:// address. */ if (dsz <= 8 || strncasecmp(d, "https://", 8)) { - warnx("%s: RFC8182 section 3.2: not using https schema", p->fn); + warnx("%s: RFC 8182 section 3.2: not using https schema", + p->fn); return 0; } @@ -167,32 +168,28 @@ static int sbgp_sia_resource_mft(struct parse *p, const unsigned char *d, size_t dsz) { - enum rtype rt; - if (p->res->mft != NULL) { warnx("%s: RFC 6487 section 4.8.8: SIA: " "MFT location already specified", p->fn); return 0; } - if ((p->res->mft = strndup((const char *)d, dsz)) == NULL) - err(1, NULL); /* Make sure it's an MFT rsync address. */ - if (!rsync_uri_parse(NULL, NULL, NULL, - NULL, NULL, NULL, &rt, p->res->mft)) { - warnx("%s: RFC 6487 section 4.8.8: SIA: " - "failed to parse rsync URI", p->fn); - free(p->res->mft); - p->res->mft = NULL; + if (dsz <= 8 || strncasecmp(d, "rsync://", 8)) { + warnx("%s: RFC 6487 section 4.8.8: not using rsync schema", + p->fn); return 0; } - if (rt != RTYPE_MFT) { + if (strcasecmp(d + dsz - 4, ".mft") != 0) { warnx("%s: RFC 6487 section 4.8.8: SIA: " "invalid rsync URI suffix", p->fn); - free(p->res->mft); - p->res->mft = NULL; return 0; } + + + if ((p->res->mft = strndup((const char *)d, dsz)) == NULL) + err(1, NULL); + return 1; } |