Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so PR/44010: YAMAMOTO Takashi: sbrk: grow 0xb...
details: https://anonhg.NetBSD.org/src/rev/39e974765c8c
branches: trunk
changeset: 758257:39e974765c8c
user: christos <christos%NetBSD.org@localhost>
date: Fri Oct 29 15:08:17 2010 +0000
description:
PR/44010: YAMAMOTO Takashi: sbrk: grow 0xb3ba2000 failed, error = 12"
(due to setenv changes?)
Provide a mini unsetenv that does not allocate/free memory and does not
bother about locking.
diffstat:
libexec/ld.elf_so/Makefile | 4 +-
libexec/ld.elf_so/rtld.c | 8 ++--
libexec/ld.elf_so/rtldenv.h | 3 +-
libexec/ld.elf_so/xenv.c | 70 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 78 insertions(+), 7 deletions(-)
diffs (145 lines):
diff -r 5fcfe6eec532 -r 39e974765c8c libexec/ld.elf_so/Makefile
--- a/libexec/ld.elf_so/Makefile Fri Oct 29 14:43:10 2010 +0000
+++ b/libexec/ld.elf_so/Makefile Fri Oct 29 15:08:17 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.97 2010/07/06 05:59:56 mrg Exp $
+# $NetBSD: Makefile,v 1.98 2010/10/29 15:08:17 christos Exp $
#
# NOTE: when changing ld.so, ensure that ldd still compiles.
#
@@ -57,7 +57,7 @@
CLIBOBJ!= cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
-SRCS+= rtld.c reloc.c symbol.c xmalloc.c xprintf.c debug.c \
+SRCS+= rtld.c reloc.c symbol.c xenv.c xmalloc.c xprintf.c debug.c \
map_object.c load.c search.c headers.c paths.c expand.c
.if ${USE_FORT} == "yes"
diff -r 5fcfe6eec532 -r 39e974765c8c libexec/ld.elf_so/rtld.c
--- a/libexec/ld.elf_so/rtld.c Fri Oct 29 14:43:10 2010 +0000
+++ b/libexec/ld.elf_so/rtld.c Fri Oct 29 15:08:17 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtld.c,v 1.131 2010/10/16 10:27:07 skrll Exp $ */
+/* $NetBSD: rtld.c,v 1.132 2010/10/29 15:08:17 christos Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.131 2010/10/16 10:27:07 skrll Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.132 2010/10/29 15:08:17 christos Exp $");
#endif /* not lint */
#include <err.h>
@@ -444,7 +444,7 @@
getenv("LD_LIBRARY_PATH"));
} else {
execname = NULL;
- if (unsetenv("LD_DEBUG") || unsetenv("LD_LIBRARY_PATH"))
+ if (xunsetenv("LD_DEBUG") || xunsetenv("LD_LIBRARY_PATH"))
_rtld_die();
}
_rtld_process_hints(execname, &_rtld_paths, &_rtld_xforms,
@@ -521,7 +521,7 @@
if (_rtld_preload(getenv("LD_PRELOAD")) == -1)
_rtld_die();
} else
- if (unsetenv("LD_PRELOAD"))
+ if (xunsetenv("LD_PRELOAD"))
_rtld_die();
dbg(("loading needed objects"));
diff -r 5fcfe6eec532 -r 39e974765c8c libexec/ld.elf_so/rtldenv.h
--- a/libexec/ld.elf_so/rtldenv.h Fri Oct 29 14:43:10 2010 +0000
+++ b/libexec/ld.elf_so/rtldenv.h Fri Oct 29 15:08:17 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtldenv.h,v 1.9 2007/10/05 22:21:07 ad Exp $ */
+/* $NetBSD: rtldenv.h,v 1.10 2010/10/29 15:08:17 christos Exp $ */
/*
* Copyright 1996 Matt Thomas <matt%3am-software.com@localhost>
@@ -59,6 +59,7 @@
void xassert(const char *, int, const char *);
const char *xstrerror(int);
+int xunsetenv(const char *);
# ifdef DEBUG
# define assert(cond) ((cond) ? (void) 0 : xassert(__FILE__, __LINE__, #cond))
diff -r 5fcfe6eec532 -r 39e974765c8c libexec/ld.elf_so/xenv.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libexec/ld.elf_so/xenv.c Fri Oct 29 15:08:17 2010 +0000
@@ -0,0 +1,70 @@
+/* $NetBSD: xenv.c,v 1.1 2010/10/29 15:08:17 christos Exp $ */
+
+/*
+ * Copyright (c) 1987, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "from: @(#)setenv.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: xenv.c,v 1.1 2010/10/29 15:08:17 christos Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#include <errno.h>
+#include <string.h>
+#include "rtldenv.h"
+
+extern char * __findenv(const char *, int *);
+extern char **environ;
+
+/*
+ * xunsetenv(name) --
+ * Delete environmental variable "name".
+ */
+int
+xunsetenv(const char *name)
+{
+ int offset;
+
+ if (name == NULL || *name == '\0' || strchr(name, '=') != NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ while (__findenv(name, &offset) != NULL) {
+ while (environ[offset] != NULL) {
+ environ[offset] = environ[offset + 1];
+ offset++;
+ }
+ }
+
+ return 0;
+}
Home |
Main Index |
Thread Index |
Old Index