Normalize the rsync caRepository to contain a trailing slash
authortb <tb@openbsd.org>
Mon, 8 Jul 2024 15:31:11 +0000 (15:31 +0000)
committertb <tb@openbsd.org>
Mon, 8 Jul 2024 15:31:11 +0000 (15:31 +0000)
discussed with jca
ok claudio

usr.sbin/rpki-client/cert.c

index c6a762f..44a2eea 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: cert.c,v 1.148 2024/06/12 10:03:09 tb Exp $ */
+/*     $OpenBSD: cert.c,v 1.149 2024/07/08 15:31:11 tb Exp $ */
 /*
  * Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
  * Copyright (c) 2021 Job Snijders <job@openbsd.org>
@@ -534,6 +534,16 @@ sbgp_sia(const char *fn, struct cert *cert, X509_EXTENSION *ext)
                                goto out;
                        if (cert->repo == NULL && strncasecmp(carepo,
                            RSYNC_PROTO, RSYNC_PROTO_LEN) == 0) {
+                               if (carepo[strlen(carepo) - 1] != '/') {
+                                       char *carepo_tmp;
+
+                                       if (asprintf(&carepo_tmp, "%s/",
+                                           carepo) == -1)
+                                               errx(1, NULL);
+                                       free(carepo);
+                                       carepo = carepo_tmp;
+                               }
+
                                cert->repo = carepo;
                                carepo = NULL;
                                continue;