summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2021-03-18 15:47:10 +0000
committerclaudio <claudio@openbsd.org>2021-03-18 15:47:10 +0000
commitec185dad6412bc222a55f3b77b8c31de679876e6 (patch)
tree95d2f01aee7877fa27b6e6fe5357499963853e06
parentAvoid NULL access in http_parse_uri() (diff)
downloadwireguard-openbsd-ec185dad6412bc222a55f3b77b8c31de679876e6.tar.xz
wireguard-openbsd-ec185dad6412bc222a55f3b77b8c31de679876e6.zip
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@
-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