diff options
Diffstat (limited to 'libexec/ld.so')
-rw-r--r-- | libexec/ld.so/dir.c | 14 | ||||
-rw-r--r-- | libexec/ld.so/dl_prebind.c | 4 | ||||
-rw-r--r-- | libexec/ld.so/ldconfig/sod.c | 8 | ||||
-rw-r--r-- | libexec/ld.so/library.c | 4 | ||||
-rw-r--r-- | libexec/ld.so/library_mquery.c | 7 | ||||
-rw-r--r-- | libexec/ld.so/library_subr.c | 4 | ||||
-rw-r--r-- | libexec/ld.so/loader.c | 7 | ||||
-rw-r--r-- | libexec/ld.so/path.c | 3 | ||||
-rw-r--r-- | libexec/ld.so/resolve.c | 7 | ||||
-rw-r--r-- | libexec/ld.so/sod.c | 11 |
10 files changed, 44 insertions, 25 deletions
diff --git a/libexec/ld.so/dir.c b/libexec/ld.so/dir.c index e2edde67e68..43b9953c699 100644 --- a/libexec/ld.so/dir.c +++ b/libexec/ld.so/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.21 2014/07/09 11:19:42 guenther Exp $ */ +/* $OpenBSD: dir.c,v 1.22 2014/07/10 09:03:01 otto Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -88,16 +88,12 @@ _dl_opendir(const char *name) int _dl_closedir(_dl_DIR *dirp) { - int fd; int ret; - fd = dirp->dd_fd; - dirp->dd_fd = -1; - dirp->dd_loc = 0; - _dl_free((void *)dirp->dd_buf); - _dl_free((void *)dirp); - ret = _dl_close(fd); - return (ret); + ret = _dl_close(dirp->dd_fd); + _dl_free(dirp->dd_buf); + _dl_free(dirp); + return ret; } diff --git a/libexec/ld.so/dl_prebind.c b/libexec/ld.so/dl_prebind.c index 0c403015226..f344dfa8bae 100644 --- a/libexec/ld.so/dl_prebind.c +++ b/libexec/ld.so/dl_prebind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dl_prebind.c,v 1.15 2014/07/06 17:33:10 otto Exp $ */ +/* $OpenBSD: dl_prebind.c,v 1.16 2014/07/10 09:03:01 otto Exp $ */ /* * Copyright (c) 2006 Dale Rahn <drahn@dalerahn.com> * @@ -201,6 +201,8 @@ prebind_symcache(elf_object_t *object, int plt) } else { objarray = _dl_reallocarray(NULL, i, sizeof(elf_object_t *)); + if (objarray == NULL) + _dl_exit(20); } obj = _dl_objects; diff --git a/libexec/ld.so/ldconfig/sod.c b/libexec/ld.so/ldconfig/sod.c index 90e4fa3efbf..183d02a22be 100644 --- a/libexec/ld.so/ldconfig/sod.c +++ b/libexec/ld.so/ldconfig/sod.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sod.c,v 1.4 2014/07/06 11:52:02 miod Exp $ */ +/* $OpenBSD: sod.c,v 1.5 2014/07/10 09:03:02 otto Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -68,6 +68,8 @@ _dl_build_sod(const char *name, struct sod *sodp) /* default is an absolute or relative path */ sodp->sod_name = (long)strdup(name); /* strtok is destructive */ + if (sodp->sod_name == 0) + exit(7); sodp->sod_library = 0; sodp->sod_major = sodp->sod_minor = 0; @@ -125,6 +127,8 @@ _dl_build_sod(const char *name, struct sod *sodp) goto backout; cp = (char *)sodp->sod_name; sodp->sod_name = (long)strdup(realname); + if (sodp->sod_name == 0) + exit(7); free(cp); sodp->sod_library = 1; sodp->sod_major = major; @@ -134,6 +138,8 @@ _dl_build_sod(const char *name, struct sod *sodp) backout: free((char *)sodp->sod_name); sodp->sod_name = (long)strdup(name); + if (sodp->sod_name == 0) + exit(7); } static struct hints_header *hheader = NULL; diff --git a/libexec/ld.so/library.c b/libexec/ld.so/library.c index b5617157cf3..b8f0f6ea6ae 100644 --- a/libexec/ld.so/library.c +++ b/libexec/ld.so/library.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library.c,v 1.69 2014/07/09 12:54:03 guenther Exp $ */ +/* $OpenBSD: library.c,v 1.70 2014/07/10 09:03:01 otto Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -196,6 +196,8 @@ _dl_tryload_shlib(const char *libname, int type, int flags) } else res = NULL; /* silence gcc */ next_load = _dl_calloc(1, sizeof(struct load_list)); + if (next_load == NULL) + _dl_exit(7); next_load->next = load_list; load_list = next_load; next_load->start = start; diff --git a/libexec/ld.so/library_mquery.c b/libexec/ld.so/library_mquery.c index 62310707977..c6fc00616a0 100644 --- a/libexec/ld.so/library_mquery.c +++ b/libexec/ld.so/library_mquery.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library_mquery.c,v 1.46 2014/07/09 12:54:03 guenther Exp $ */ +/* $OpenBSD: library_mquery.c,v 1.47 2014/07/10 09:03:01 otto Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -158,8 +158,9 @@ _dl_tryload_shlib(const char *libname, int type, int flags) size = off + phdp->p_filesz; if (size != 0) { - /* XXX */ ld = _dl_malloc(sizeof(struct load_list)); + if (ld == NULL) + _dl_exit(7); ld->start = NULL; ld->size = size; ld->moff = TRUNC_PG(phdp->p_vaddr); @@ -173,6 +174,8 @@ _dl_tryload_shlib(const char *libname, int type, int flags) break; /* This phdr has a zfod section */ ld = _dl_calloc(1, sizeof(struct load_list)); + if (ld == NULL) + _dl_exit(7); ld->start = NULL; ld->size = ROUND_PG(off + phdp->p_memsz) - ROUND_PG(size); diff --git a/libexec/ld.so/library_subr.c b/libexec/ld.so/library_subr.c index 682ee628b1d..13d27d6ba81 100644 --- a/libexec/ld.so/library_subr.c +++ b/libexec/ld.so/library_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: library_subr.c,v 1.40 2014/07/06 17:33:10 otto Exp $ */ +/* $OpenBSD: library_subr.c,v 1.41 2014/07/10 09:03:01 otto Exp $ */ /* * Copyright (c) 2002 Dale Rahn @@ -317,6 +317,8 @@ _dl_load_shlib(const char *libname, elf_object_t *parent, int type, int flags) char *paths[2]; char *lpath, *lname; lpath = _dl_strdup(libname); + if (lpath == NULL) + _dl_exit(5); lname = _dl_strrchr(lpath, '/'); if (lname == NULL) { _dl_free(lpath); diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c index 75e37f339ac..c5449df8901 100644 --- a/libexec/ld.so/loader.c +++ b/libexec/ld.so/loader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: loader.c,v 1.149 2014/07/06 19:15:16 otto Exp $ */ +/* $OpenBSD: loader.c,v 1.150 2014/07/10 09:03:01 otto Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -461,6 +461,8 @@ _dl_boot(const char **argv, char **envp, const long dyn_loff, long *dl_data) maxva = phdp->p_vaddr + phdp->p_memsz; next_load = _dl_calloc(1, sizeof(struct load_list)); + if (next_load == NULL) + _dl_exit(5); next_load->next = load_list; load_list = next_load; next_load->start = (char *)TRUNC_PG(phdp->p_vaddr) + exe_loff; @@ -562,8 +564,9 @@ _dl_boot(const char **argv, char **envp, const long dyn_loff, long *dl_data) DL_DEB(("failed to mark DTDEBUG\n")); } if (map_link) { - /* XXX */ debug_map = (struct r_debug *)_dl_malloc(sizeof(*debug_map)); + if (debug_map == NULL) + _dl_exit(5); debug_map->r_version = 1; debug_map->r_map = (struct link_map *)_dl_objects; debug_map->r_brk = (Elf_Addr)_dl_debug_state; diff --git a/libexec/ld.so/path.c b/libexec/ld.so/path.c index 239b6e86f06..48fe67c95db 100644 --- a/libexec/ld.so/path.c +++ b/libexec/ld.so/path.c @@ -1,4 +1,4 @@ -/* $OpenBSD: path.c,v 1.2 2014/06/21 08:00:23 otto Exp $ */ +/* $OpenBSD: path.c,v 1.3 2014/07/10 09:03:01 otto Exp $ */ /* * Copyright (c) 2013 Kurt Miller <kurt@intricatesoftware.com> @@ -44,7 +44,6 @@ _dl_split_path(const char *searchpath) count++; retval = _dl_reallocarray(NULL, count, sizeof(retval)); - if (retval == NULL) return (NULL); diff --git a/libexec/ld.so/resolve.c b/libexec/ld.so/resolve.c index 09ec28631b3..bdcabe20024 100644 --- a/libexec/ld.so/resolve.c +++ b/libexec/ld.so/resolve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolve.c,v 1.66 2014/06/21 08:00:23 otto Exp $ */ +/* $OpenBSD: resolve.c,v 1.67 2014/07/10 09:03:01 otto Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -246,6 +246,8 @@ _dl_finalize_object(const char *objname, Elf_Dyn *dynp, Elf_Phdr *phdrp, objname, dynp, objtype, lbase, obase); #endif object = _dl_calloc(1, sizeof(elf_object_t)); + if (object == NULL) + _dl_exit(7); object->prev = object->next = NULL; object->load_dyn = dynp; @@ -329,8 +331,9 @@ _dl_finalize_object(const char *objname, Elf_Dyn *dynp, Elf_Phdr *phdrp, object->phdrc = phdrc; object->load_base = lbase; object->obj_base = obase; - /* XXX */ object->load_name = _dl_strdup(objname); + if (object->load_name == NULL) + _dl_exit(7); object->load_object = _dl_loading_object; if (object->load_object == object) DL_DEB(("head %s\n", object->load_name)); diff --git a/libexec/ld.so/sod.c b/libexec/ld.so/sod.c index a0464f04664..adeff54a22d 100644 --- a/libexec/ld.so/sod.c +++ b/libexec/ld.so/sod.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sod.c,v 1.30 2014/07/09 12:54:03 guenther Exp $ */ +/* $OpenBSD: sod.c,v 1.31 2014/07/10 09:03:01 otto Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -64,8 +64,9 @@ _dl_build_sod(const char *name, struct sod *sodp) char *realname, *tok, *etok, *cp; /* default is an absolute or relative path */ - /* XXX */ sodp->sod_name = (long)_dl_strdup(name); /* strtok is destructive */ + if (sodp->sod_name == 0) + _dl_exit(7); sodp->sod_library = 0; sodp->sod_major = sodp->sod_minor = 0; @@ -122,8 +123,9 @@ _dl_build_sod(const char *name, struct sod *sodp) if (realname == NULL) goto backout; cp = (char *)sodp->sod_name; - /* XXX */ sodp->sod_name = (long)_dl_strdup(realname); + if (sodp->sod_name == 0) + _dl_exit(7); _dl_free(cp); sodp->sod_library = 1; sodp->sod_major = major; @@ -132,8 +134,9 @@ _dl_build_sod(const char *name, struct sod *sodp) backout: _dl_free((char *)sodp->sod_name); - /* XXX */ sodp->sod_name = (long)_dl_strdup(name); + if (sodp->sod_name == 0) + _dl_exit(7); } void |