summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2021-03-18 15:47:11 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2021-03-18 15:47:11 +0000
commit2a9d37790409123af0a2b948b8329f629416b17c (patch)
tree1135c276a65ea29c79f5ca85821b3aa6b131a4f3 /usr.sbin
parentb55c4bf7123d3b5044f3ba52a6f154da6a806fa6 (diff)
Fail in rsync_base_uri() if the strdup calls fail. Do not bubble this
error upwards since a NULL return represents a bad-URI. Diff originally from tb@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/rpki-client/rsync.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/rpki-client/rsync.c b/usr.sbin/rpki-client/rsync.c
index e1c9cd71de6..5f6e16914ed 100644
--- a/usr.sbin/rpki-client/rsync.c
+++ b/usr.sbin/rpki-client/rsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsync.c,v 1.21 2021/03/04 14:24:17 claudio Exp $ */
+/* $OpenBSD: rsync.c,v 1.22 2021/03/18 15:47:10 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -55,6 +55,7 @@ char *
rsync_base_uri(const char *uri)
{
const char *host, *module, *rest;
+ char *base_uri;
/* Case-insensitive rsync URI. */
if (strncasecmp(uri, "rsync://", 8) != 0) {
@@ -82,13 +83,17 @@ rsync_base_uri(const char *uri)
/* The path component is optional. */
if ((rest = strchr(module, '/')) == NULL) {
- return strdup(uri);
+ if ((base_uri = strdup(uri)) == NULL)
+ err(1, NULL);
+ return base_uri;
} else if (rest == module) {
warnx("%s: zero-length module", uri);
return NULL;
}
- return strndup(uri, rest - uri);
+ if ((base_uri = strndup(uri, rest - uri)) == NULL)
+ err(1, NULL);
+ return base_uri;
}
static void