2004-05-25  Ulrich Drepper  <drepper@redhat.com>

	* nss/digits_dots.c (__nss_hostname_digits_dots): Remove typep and
	flags parameter, convert afp to simple int parameter.  Adjust code.
	typep was never != NULL and flags therefore also unused.  *afp is
	never modified.
	* nss/nsswitch.h: Adjust __nss_hostname_digits_dots prototype.
	* nss/getXXbyYY.c: Remove HAVE_TYPE handling.  Adjust af parameter
	handling for __nss_hostname_digits_dots calls.
	* nss/getXXbyYY_r.c: Likewise.

	* elf/dl-load.c (_dl_map_object_from_fd): Map DSOs with MAP_DENYWRITE.
This commit is contained in:
Ulrich Drepper 2004-05-26 06:42:16 +00:00
parent ffdd5e50e1
commit 1773d1ba5f
7 changed files with 55 additions and 123 deletions

View file

@ -1,3 +1,16 @@
2004-05-25 Ulrich Drepper <drepper@redhat.com>
* nss/digits_dots.c (__nss_hostname_digits_dots): Remove typep and
flags parameter, convert afp to simple int parameter. Adjust code.
typep was never != NULL and flags therefore also unused. *afp is
never modified.
* nss/nsswitch.h: Adjust __nss_hostname_digits_dots prototype.
* nss/getXXbyYY.c: Remove HAVE_TYPE handling. Adjust af parameter
handling for __nss_hostname_digits_dots calls.
* nss/getXXbyYY_r.c: Likewise.
* elf/dl-load.c (_dl_map_object_from_fd): Map DSOs with MAP_DENYWRITE.
2004-05-25 Steven Munroe <sjmunroe@us.ibm.com>
* sysdeps/powerpc/fpu/Makefile: Make ld.so a dependency of libm.so.

View file

@ -53,6 +53,12 @@
# define MAP_COPY MAP_PRIVATE
#endif
/* We want to prevent people from modifying DSOs which are currently in
use. This is what MAP_DENYWRITE is for. */
#ifndef MAP_DENYWRITE
# define MAP_DENYWRITE 0
#endif
/* Some systems link their relocatable objects for another base address
than 0. We want to know the base address for these such that we can
subtract this address from the segment addresses during mapping.
@ -1092,7 +1098,8 @@ cannot allocate TLS data structures for initial thread");
/* Remember which part of the address space this object uses. */
l->l_map_start = (ElfW(Addr)) __mmap ((void *) mappref, maplength,
c->prot, MAP_COPY | MAP_FILE,
c->prot,
MAP_COPY|MAP_FILE|MAP_DENYWRITE,
fd, c->mapoff);
if (__builtin_expect ((void *) l->l_map_start == MAP_FAILED, 0))
{
@ -1141,7 +1148,8 @@ cannot allocate TLS data structures for initial thread");
/* Map the segment contents from the file. */
&& (__mmap ((void *) (l->l_addr + c->mapstart),
c->mapend - c->mapstart, c->prot,
MAP_FIXED | MAP_COPY | MAP_FILE, fd, c->mapoff)
MAP_FIXED|MAP_COPY|MAP_FILE|MAP_DENYWRITE,
fd, c->mapoff)
== MAP_FAILED))
goto map_error;

View file

@ -171,52 +171,16 @@ struct obstack /* control current object in current chunk */
/* Declare the external functions we use; they are in obstack.c. */
extern void _obstack_newchunk (struct obstack *, int);
extern void _obstack_free (struct obstack *, void *);
extern int _obstack_begin (struct obstack *, int, int,
void *(*) (long), void (*) (void *));
extern int _obstack_begin_1 (struct obstack *, int, int,
void *(*) (void *, long),
void (*) (void *, void *), void *);
extern int _obstack_memory_used (struct obstack *);
/* Do the function-declarations after the structs
but before defining the macros. */
void obstack_init (struct obstack *obstack);
void * obstack_alloc (struct obstack *obstack, int size);
void * obstack_copy (struct obstack *obstack, const void *address, int size);
void * obstack_copy0 (struct obstack *obstack, const void *address, int size);
void obstack_free (struct obstack *obstack, void *block);
void obstack_blank (struct obstack *obstack, int size);
void obstack_grow (struct obstack *obstack, const void *data, int size);
void obstack_grow0 (struct obstack *obstack, const void *data, int size);
void obstack_1grow (struct obstack *obstack, int data_char);
void obstack_ptr_grow (struct obstack *obstack, const void *data);
void obstack_int_grow (struct obstack *obstack, int data);
void * obstack_finish (struct obstack *obstack);
int obstack_object_size (struct obstack *obstack);
int obstack_room (struct obstack *obstack);
void obstack_make_room (struct obstack *obstack, int size);
void obstack_1grow_fast (struct obstack *obstack, int data_char);
void obstack_ptr_grow_fast (struct obstack *obstack, const void *data);
void obstack_int_grow_fast (struct obstack *obstack, int data);
void obstack_blank_fast (struct obstack *obstack, int size);
void * obstack_base (struct obstack *obstack);
void * obstack_next_free (struct obstack *obstack);
int obstack_alignment_mask (struct obstack *obstack);
int obstack_chunk_size (struct obstack *obstack);
int obstack_memory_used (struct obstack *obstack);
/* Error handler called when `obstack_chunk_alloc' failed to allocate
more memory. This can be set to a user defined function which
should either abort gracefully or use longjump - but shouldn't

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
/* Copyright (C) 1997, 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by H.J. Lu <hjl@gnu.ai.mit.edu>, 1997.
@ -37,8 +37,7 @@ int
__nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
char **buffer, size_t *buffer_size,
size_t buflen, struct hostent **result,
enum nss_status *status, int *typep,
int flags, int *afp, int *h_errnop)
enum nss_status *status, int af, int *h_errnop)
{
int save;
@ -67,14 +66,6 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
char **h_alias_ptr;
size_t size_needed;
int addr_size;
int af;
if (typep != NULL)
af = *typep;
else if (afp != NULL)
af = *afp;
else
af = -1;
switch (af)
{
@ -87,18 +78,8 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
break;
default:
if (typep != NULL)
{
/* This must not happen. */
if (h_errnop != NULL)
*h_errnop = HOST_NOT_FOUND;
goto done;
}
else
{
af = (_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET;
addr_size = af == AF_INET6 ? IN6ADDRSZ : INADDRSZ;
}
af = (_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET;
addr_size = af == AF_INET6 ? IN6ADDRSZ : INADDRSZ;
break;
}
@ -180,38 +161,25 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
(*h_addr_ptrs)[0] = (char *) host_addr;
(*h_addr_ptrs)[1] = NULL;
resbuf->h_addr_list = *h_addr_ptrs;
if ((typep != NULL && *typep == AF_INET6)
|| (af == AF_INET
&& (_res.options & RES_USE_INET6)))
if (af == AF_INET && (_res.options & RES_USE_INET6))
{
if (typep != NULL && (flags & AI_V4MAPPED) == 0)
{
/* That's bad. The user hasn't specified that she
allows IPv4 numeric addresses. */
*result = NULL;
*h_errnop = HOST_NOT_FOUND;
goto done;
}
else
{
/* We need to change the IP v4 address into the
IP v6 address. */
char tmp[INADDRSZ];
char *p = (char *) host_addr;
int i;
/* We need to change the IP v4 address into the
IP v6 address. */
char tmp[INADDRSZ];
char *p = (char *) host_addr;
int i;
/* Save a copy of the IP v4 address. */
memcpy (tmp, host_addr, INADDRSZ);
/* Mark this ipv6 addr as a mapped ipv4. */
for (i = 0; i < 10; i++)
*p++ = 0x00;
*p++ = 0xff;
*p++ = 0xff;
/* Copy the IP v4 address. */
memcpy (p, tmp, INADDRSZ);
resbuf->h_addrtype = AF_INET6;
resbuf->h_length = IN6ADDRSZ;
}
/* Save a copy of the IP v4 address. */
memcpy (tmp, host_addr, INADDRSZ);
/* Mark this ipv6 addr as a mapped ipv4. */
for (i = 0; i < 10; i++)
*p++ = 0x00;
*p++ = 0xff;
*p++ = 0xff;
/* Copy the IP v4 address. */
memcpy (p, tmp, INADDRSZ);
resbuf->h_addrtype = AF_INET6;
resbuf->h_length = IN6ADDRSZ;
}
else
{
@ -242,14 +210,6 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
host_addr_list_t *h_addr_ptrs;
size_t size_needed;
int addr_size;
int af;
if (typep != NULL)
af = *typep;
else if (afp != NULL)
af = *afp;
else
af = -1;
switch (af)
{

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1996-2001,2003 Free Software Foundation, Inc.
/* Copyright (C) 1996-2001,2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -66,15 +66,10 @@
# define H_ERRNO_VAR_P NULL
#endif
#ifndef HAVE_TYPE
# define TYPE_VAR_P NULL
# define FLAGS_VAR 0
#endif
#ifdef HAVE_AF
# define AF_VAR_P &af
# define AF_VAL af
#else
# define AF_VAR_P NULL
# define AF_VAL AF_INET
#endif
/* Prototype for reentrant version we use here. */
@ -112,9 +107,7 @@ FUNCTION_NAME (ADD_PARAMS)
if (buffer != NULL)
{
if (__nss_hostname_digits_dots (name, &resbuf, &buffer,
&buffer_size,
0, &result, NULL, TYPE_VAR_P,
FLAGS_VAR, AF_VAR_P,
&buffer_size, 0, &result, NULL, AF_VAL,
H_ERRNO_VAR_P))
goto done;
}

View file

@ -99,15 +99,10 @@
# define H_ERRNO_VAR_P NULL
#endif
#ifndef HAVE_TYPE
# define TYPE_VAR_P NULL
# define FLAGS_VAR 0
#endif
#ifdef HAVE_AF
# define AF_VAR_P &af
# define AF_VAL af
#else
# define AF_VAR_P NULL
# define AF_VAL AF_INET
#endif
/* Type of the lookup function we need here. */
@ -151,8 +146,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
#ifdef HANDLE_DIGITS_DOTS
switch (__nss_hostname_digits_dots (name, resbuf, &buffer, NULL,
buflen, result, &status,
TYPE_VAR_P, FLAGS_VAR, AF_VAR_P,
buflen, result, &status, AF_VAL,
H_ERRNO_VAR_P))
{
case -1:

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1996-1999,2001,2002,2003 Free Software Foundation, Inc.
/* Copyright (C) 1996-1999,2001,2002,2003,2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -172,8 +172,8 @@ extern int __nss_hostname_digits_dots (const char *name,
struct hostent *resbuf, char **buffer,
size_t *buffer_size, size_t buflen,
struct hostent **result,
enum nss_status *status, int *typep,
int flags, int *afp, int *h_errnop);
enum nss_status *status, int af,
int *h_errnop);
libc_hidden_proto (__nss_hostname_digits_dots)
#endif /* nsswitch.h */