This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi!
The first hunk is the most important. Fixes a bug where e.g. with overly
long /etc/hosts entries gethostbyname etc. work only when nscd is turned
off but fail when it is running. The problem is that if h_errno is not set
to NETDB_INTERNAL, the non-_r functions don't consider ERANGE as being
because the buffer was too small and don't retry with a larger size.
The rest of the changes is just something I have noticed during the
debugging - there were a few places which grew the buffer sizes linearly,
which is really slow for very big answers. The other places have been
fixed before already to DTRT.
2005-02-21 Jakub Jelinek <jakub@redhat.com>
* nscd/nscd_gethst_r.c (nscd_gethst_r): Set *h_errnop to
NETDB_INTERNAL if buffer is too small.
* nscd/hstcache.c (INCR): Remove.
(addhstbyX): Double buflen in each iteration rather than add INCR.
* nscd/grpcache.c (INCR): Remove.
(addgrbyX): Double buflen in each iteration rather than add INCR.
* nscd/pwdcache.c (INCR): Remove.
(addpwbyX): Double buflen in each iteration rather than add INCR.
--- libc/nscd/nscd_gethst_r.c.jj 2004-11-10 10:30:32.000000000 +0100
+++ libc/nscd/nscd_gethst_r.c 2005-02-21 21:34:28.644218762 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -218,6 +218,7 @@ nscd_gethst_r (const char *key, size_t k
? INADDRSZ : IN6ADDRSZ)))
{
no_room:
+ *h_errnop = NETDB_INTERNAL;
__set_errno (ERANGE);
retval = ERANGE;
goto out_close;
--- libc/nscd/hstcache.c.jj 2005-01-26 18:36:40.000000000 +0100
+++ libc/nscd/hstcache.c 2005-02-21 21:28:50.806168914 +0100
@@ -1,5 +1,5 @@
/* Cache handling for host lookup.
- Copyright (C) 1998-2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -453,11 +453,10 @@ addhstbyX (struct database_dyn *db, int
{
char *old_buffer = buffer;
errno = 0;
-#define INCR 1024
if (__builtin_expect (buflen > 32768, 0))
{
- buflen += INCR;
+ buflen *= 2;
buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen);
if (buffer == NULL)
{
@@ -478,7 +477,7 @@ addhstbyX (struct database_dyn *db, int
else
/* Allocate a new buffer on the stack. If possible combine it
with the previously allocated buffer. */
- buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR);
+ buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
}
#if 0
--- libc/nscd/grpcache.c.jj 2005-01-26 18:36:40.000000000 +0100
+++ libc/nscd/grpcache.c 2005-02-21 21:30:49.876047695 +0100
@@ -1,5 +1,5 @@
/* Cache handling for group lookup.
- Copyright (C) 1998-2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -429,11 +429,10 @@ addgrbyX (struct database_dyn *db, int f
{
char *old_buffer = buffer;
errno = 0;
-#define INCR 1024
if (__builtin_expect (buflen > 32768, 0))
{
- buflen += INCR;
+ buflen *= 2;
buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen);
if (buffer == NULL)
{
@@ -454,7 +453,7 @@ addgrbyX (struct database_dyn *db, int f
else
/* Allocate a new buffer on the stack. If possible combine it
with the previously allocated buffer. */
- buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR);
+ buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
}
#if 0
--- libc/nscd/pwdcache.c.jj 2005-01-26 18:36:40.000000000 +0100
+++ libc/nscd/pwdcache.c 2005-02-21 21:31:14.872612500 +0100
@@ -1,5 +1,5 @@
/* Cache handling for passwd lookup.
- Copyright (C) 1998-2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -425,11 +425,10 @@ addpwbyX (struct database_dyn *db, int f
{
char *old_buffer = buffer;
errno = 0;
-#define INCR 1024
if (__builtin_expect (buflen > 32768, 0))
{
- buflen += INCR;
+ buflen *= 2;
buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen);
if (buffer == NULL)
{
@@ -450,7 +449,7 @@ addpwbyX (struct database_dyn *db, int f
else
/* Allocate a new buffer on the stack. If possible combine it
with the previously allocated buffer. */
- buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR);
+ buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
}
#if 0
Jakub
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |