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.
This commit is contained in:
parent
a62c9cdf52
commit
acfd35dad9
@ -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 @@ PROG= ld.elf_so
|
||||
|
||||
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"
|
||||
|
@ -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 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase)
|
||||
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 @@ _rtld(Elf_Addr *sp, Elf_Addr relocbase)
|
||||
if (_rtld_preload(getenv("LD_PRELOAD")) == -1)
|
||||
_rtld_die();
|
||||
} else
|
||||
if (unsetenv("LD_PRELOAD"))
|
||||
if (xunsetenv("LD_PRELOAD"))
|
||||
_rtld_die();
|
||||
|
||||
dbg(("loading needed objects"));
|
||||
|
@ -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>
|
||||
@ -59,6 +59,7 @@ void xerrx(int, const char *, ...)
|
||||
|
||||
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))
|
||||
|
70
libexec/ld.elf_so/xenv.c
Normal file
70
libexec/ld.elf_so/xenv.c
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user