diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2015-09-06 08:44:08 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2015-09-06 08:44:08 +0000 |
commit | 927ffb6b96c93229147711b75f1c80109b8598da (patch) | |
tree | f125cb9ac1cc71f0a6776d7e4eac55881a5321bd /libexec/ld.so | |
parent | 1668f0d5573dd028286bba59c745a1c49098494b (diff) |
Check strdup return value for NULL.
ok millert@
Diffstat (limited to 'libexec/ld.so')
-rw-r--r-- | libexec/ld.so/ldconfig/library.c | 4 | ||||
-rw-r--r-- | libexec/ld.so/ldconfig/prebind.c | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/libexec/ld.so/ldconfig/library.c b/libexec/ld.so/ldconfig/library.c index e3747388fd2..771d9b5c510 100644 --- a/libexec/ld.so/ldconfig/library.c +++ b/libexec/ld.so/ldconfig/library.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library.c,v 1.9 2015/06/10 20:50:05 miod Exp $ */ +/* $OpenBSD: library.c,v 1.10 2015/09/06 08:44:07 tobias Exp $ */ /* * Copyright (c) 2006 Dale Rahn <drahn@dalerahn.com> * @@ -60,6 +60,8 @@ load_lib(const char *name, struct elf_object *parent) char *lpath, *lname; lpath = strdup(name); + if (lpath == NULL) + return (1); lname = strrchr(lpath, '/'); if (lname == NULL || lname[1] == '\0') { free(lpath); diff --git a/libexec/ld.so/ldconfig/prebind.c b/libexec/ld.so/ldconfig/prebind.c index 785929b7663..f3cdc06d665 100644 --- a/libexec/ld.so/ldconfig/prebind.c +++ b/libexec/ld.so/ldconfig/prebind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: prebind.c,v 1.29 2015/06/03 02:24:36 millert Exp $ */ +/* $OpenBSD: prebind.c,v 1.30 2015/09/06 08:44:07 tobias Exp $ */ /* * Copyright (c) 2006 Dale Rahn <drahn@dalerahn.com> * @@ -518,6 +518,10 @@ elf_load_object(void *pexe, const char *name) object->load_base = lbase; object->load_name = strdup(name); + if (object->load_name == NULL) { + printf("unable to allocate object for %s\n", name); + exit(10); + } phdr = (Elf_Phdr *)((char *)pexe + ehdr->e_phoff); for (i = 0; i < ehdr->e_phnum; i++) { @@ -529,6 +533,11 @@ elf_load_object(void *pexe, const char *name) /* XXX can only occur in programs */ curbin->interp = strdup((char *)((char *)pexe + phdr[i].p_offset)); + if (curbin->interp == NULL) { + printf("unable to allocate object for %s\n", + name); + exit(10); + } break; default: break; |