summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2019-12-17 17:16:32 +0000
committerguenther <guenther@openbsd.org>2019-12-17 17:16:32 +0000
commit3d8e19a1e88234ef8b946d7c79832ee657fb249a (patch)
tree81d1c77086b743099a2a799f4e976f14cba8bc44
parentcorrect some uses of .Nm (diff)
downloadwireguard-openbsd-3d8e19a1e88234ef8b946d7c79832ee657fb249a.tar.xz
wireguard-openbsd-3d8e19a1e88234ef8b946d7c79832ee657fb249a.zip
Eliminate failure returns from _dl_split_path(): if malloc fails just _dl_oom()
Prompted by Qualys's leveraging malloc failure in _dl_split_path() to get stuff past. ok deraadt@ millert@
-rw-r--r--libexec/ld.so/ldconfig/etc.c8
-rw-r--r--libexec/ld.so/path.c10
2 files changed, 10 insertions, 8 deletions
diff --git a/libexec/ld.so/ldconfig/etc.c b/libexec/ld.so/ldconfig/etc.c
index b8f3eb07e33..3d912f135c3 100644
--- a/libexec/ld.so/ldconfig/etc.c
+++ b/libexec/ld.so/ldconfig/etc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: etc.c,v 1.7 2006/05/12 23:35:16 deraadt Exp $ */
+/* $OpenBSD: etc.c,v 1.8 2019/12/17 17:16:32 guenther Exp $ */
/* Public Domain */
@@ -11,6 +11,12 @@
#define OOM_MSG "Out of memory"
+__dead void
+_dl_oom(void)
+{
+ err(1, OOM_MSG);
+}
+
char *
xstrdup(const char *s)
{
diff --git a/libexec/ld.so/path.c b/libexec/ld.so/path.c
index f0dd706e3a9..657a1fdcd88 100644
--- a/libexec/ld.so/path.c
+++ b/libexec/ld.so/path.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: path.c,v 1.7 2017/06/22 20:44:36 benno Exp $ */
+/* $OpenBSD: path.c,v 1.8 2019/12/17 17:16:32 guenther Exp $ */
/*
* Copyright (c) 2013 Kurt Miller <kurt@intricatesoftware.com>
@@ -44,7 +44,7 @@ _dl_split_path(const char *searchpath)
retval = _dl_reallocarray(NULL, count, sizeof(*retval));
if (retval == NULL)
- return (NULL);
+ _dl_oom();
pp = searchpath;
while (pp) {
@@ -55,7 +55,7 @@ _dl_split_path(const char *searchpath)
if (p_begin != pp) {
retval[pos] = _dl_malloc(pp - p_begin + 1);
if (retval[pos] == NULL)
- goto badret;
+ _dl_oom();
_dl_bcopy(p_begin, retval[pos], pp - p_begin);
retval[pos++][pp - p_begin] = '\0';
@@ -69,10 +69,6 @@ _dl_split_path(const char *searchpath)
retval[pos] = NULL;
return (retval);
-
-badret:
- _dl_free_path(retval);
- return (NULL);
}
void