From 58058fa2e673f6a6f1a94a7ec1cd3ba172401fd8 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 15 Oct 2007 23:02:24 +0000 Subject: (REENTRANT_NAME): Mangle start and start_fct pointers. --- nss/getXXbyYY_r.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'nss') diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c index 080163a..6c90ba5 100644 --- a/nss/getXXbyYY_r.c +++ b/nss/getXXbyYY_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2002, 2003, 2004, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1996-2004, 2006, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -22,6 +22,7 @@ #include #include #include "nsswitch.h" +#include "sysdep.h" #ifdef USE_NSCD # include #endif @@ -120,6 +121,7 @@ int INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer, size_t buflen, LOOKUP_TYPE **result H_ERRNO_PARM) { + static bool startp_initialized; static service_user *startp; static lookup_function start_fct; service_user *nip; @@ -167,11 +169,15 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer, } #endif - if (startp == NULL) + if (! startp_initialized) { no_more = DB_LOOKUP_FCT (&nip, REENTRANT_NAME_STRING, &fct.ptr); if (no_more) - startp = (service_user *) -1l; + { + void *tmp_ptr = (service_user *) -1l; + PTR_MANGLE (tmp_ptr); + startp = tmp_ptr; + } else { #ifdef NEED__RES @@ -189,16 +195,26 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer, _res_hconf_init (); #endif /* need _res_hconf */ - start_fct = fct.l; - /* Make sure start_fct is written before startp. */ - atomic_write_barrier (); - startp = nip; + void *tmp_ptr = fct.l; + PTR_MANGLE (tmp_ptr); + start_fct = tmp_ptr; + tmp_ptr = nip; + PTR_MANGLE (tmp_ptr); + startp = tmp_ptr; } + + /* Make sure start_fct and startp are written before + startp_initialized. */ + atomic_write_barrier (); + startp_initialized = true; } else { fct.l = start_fct; - no_more = (nip = startp) == (service_user *) -1l; + PTR_DEMANGLE (fct.l); + nip = startp; + PTR_DEMANGLE (nip); + no_more = nip == (service_user *) -1l; } while (no_more == 0) -- cgit v1.1