don't let readlink trash errno.;
This commit is contained in:
parent
6a0660a9b0
commit
1ff5a5dfd6
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: jemalloc.c,v 1.22 2011/02/26 23:27:49 njoly Exp $ */
|
||||
/* $NetBSD: jemalloc.c,v 1.23 2011/05/13 23:11:00 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 2006,2007 Jason Evans <jasone@FreeBSD.org>.
|
||||
|
@ -118,7 +118,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
/* __FBSDID("$FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.147 2007/06/15 22:00:16 jasone Exp $"); */
|
||||
__RCSID("$NetBSD: jemalloc.c,v 1.22 2011/02/26 23:27:49 njoly Exp $");
|
||||
__RCSID("$NetBSD: jemalloc.c,v 1.23 2011/05/13 23:11:00 christos Exp $");
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include "libc_private.h"
|
||||
|
@ -3325,6 +3325,7 @@ malloc_init_hard(void)
|
|||
ssize_t linklen;
|
||||
char buf[PATH_MAX + 1];
|
||||
const char *opts = "";
|
||||
int serrno;
|
||||
|
||||
malloc_mutex_lock(&init_lock);
|
||||
if (malloc_initialized) {
|
||||
|
@ -3371,6 +3372,7 @@ malloc_init_hard(void)
|
|||
/* Get runtime configuration. */
|
||||
switch (i) {
|
||||
case 0:
|
||||
serrno = errno;
|
||||
if ((linklen = readlink("/etc/malloc.conf", buf,
|
||||
sizeof(buf) - 1)) != -1) {
|
||||
/*
|
||||
|
@ -3380,6 +3382,7 @@ malloc_init_hard(void)
|
|||
buf[linklen] = '\0';
|
||||
opts = buf;
|
||||
} else {
|
||||
errno = serrno;
|
||||
/* No configuration specified. */
|
||||
buf[0] = '\0';
|
||||
opts = buf;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: malloc.c,v 1.52 2008/02/03 22:56:53 christos Exp $ */
|
||||
/* $NetBSD: malloc.c,v 1.53 2011/05/13 23:11:00 christos Exp $ */
|
||||
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
|
@ -90,7 +90,7 @@ void utrace(struct ut *, int);
|
|||
#include <sys/cdefs.h>
|
||||
#include "extern.h"
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: malloc.c,v 1.52 2008/02/03 22:56:53 christos Exp $");
|
||||
__RCSID("$NetBSD: malloc.c,v 1.53 2011/05/13 23:11:00 christos Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
int utrace(const char *, void *, size_t);
|
||||
|
||||
|
@ -467,9 +467,12 @@ malloc_init(void)
|
|||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (i == 0) {
|
||||
int serrno = errno;
|
||||
j = readlink("/etc/malloc.conf", b, sizeof b - 1);
|
||||
if (j <= 0)
|
||||
if (j == -1) {
|
||||
errno = serrno;
|
||||
continue;
|
||||
}
|
||||
b[j] = '\0';
|
||||
p = b;
|
||||
} else if (i == 1 && issetugid() == 0) {
|
||||
|
|
Loading…
Reference in New Issue