1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-18 07:13:36 +02:00

Add some guardrails to rsync_base_uri() against future programmer error

OK tb@
This commit is contained in:
job
2026-06-15 14:45:19 +00:00
parent 91fddc0d93
commit 10c123100a
2 changed files with 6 additions and 4 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: repo.c,v 1.83 2026/06/15 14:30:53 job Exp $ */
/* $OpenBSD: repo.c,v 1.84 2026/06/15 14:45:19 job Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -480,7 +480,7 @@ static struct rsyncrepo *
rsync_get(const char *uri, const char *validdir)
{
struct rsyncrepo *rr;
char *repo;
char *repo = NULL;
if (!rsync_base_uri(uri, &repo))
errx(1, "bad caRepository URI: %s", uri);
@@ -1225,7 +1225,7 @@ struct repo *
repo_lookup(int talid, const char *uri, const char *notify)
{
struct repo *rp;
char *repouri;
char *repouri = NULL;
if (!rsync_base_uri(uri, &repouri))
errx(1, "bad caRepository URI: %s", uri);
+3 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: rsync.c,v 1.63 2026/06/15 14:30:53 job Exp $ */
/* $OpenBSD: rsync.c,v 1.64 2026/06/15 14:45:19 job Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -66,6 +66,8 @@ rsync_base_uri(const char *uri, char **out_base_uri)
{
const char *host, *module, *rest;
assert(out_base_uri == NULL || *out_base_uri == NULL);
/* Case-insensitive rsync URI. */
if (strncasecmp(uri, RSYNC_PROTO, RSYNC_PROTO_LEN) != 0) {
warnx("%s: not using rsync schema", uri);