summaryrefslogtreecommitdiff
path: root/inet
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-12-12 18:13:35 +0000
committerJakub Jelinek <jakub@redhat.com>2007-12-12 18:13:35 +0000
commit574e283890a6ca92325a06dafa76ff307a8019a2 (patch)
tree055e44e24a55fb4863e5d9cdc04e320cde52ffe9 /inet
parenta162e5955f7e324be82d9318bbcbe869c66ffb86 (diff)
Updated to fedora-glibc-20071212T1051
Diffstat (limited to 'inet')
-rw-r--r--inet/Makefile4
-rw-r--r--inet/ether_hton.c4
-rw-r--r--inet/ether_line.c15
-rw-r--r--inet/ether_ntoh.c4
-rw-r--r--inet/gethstbyad_r.c4
-rw-r--r--inet/gethstbynm2_r.c4
-rw-r--r--inet/gethstbynm_r.c4
-rw-r--r--inet/gethstent_r.c4
-rw-r--r--inet/getnetgrent_r.c33
-rw-r--r--inet/tst-ether_line.c38
10 files changed, 82 insertions, 32 deletions
diff --git a/inet/Makefile b/inet/Makefile
index 5823b69e9c..d7139c1d7f 100644
--- a/inet/Makefile
+++ b/inet/Makefile
@@ -49,10 +49,10 @@ routines := htonl htons \
getipv4sourcefilter setipv4sourcefilter \
getsourcefilter setsourcefilter inet6_opt inet6_rth
-aux := check_pf ifreq
+aux := check_pf check_native ifreq
tests := htontest test_ifindex tst-ntoa tst-ether_aton tst-network \
- tst-gethnm test-ifaddrs bug-if1 test-inet6_opt
+ tst-gethnm test-ifaddrs bug-if1 test-inet6_opt tst-ether_line
include ../Rules
diff --git a/inet/ether_hton.c b/inet/ether_hton.c
index 64f5ab5d36..2bff47d472 100644
--- a/inet/ether_hton.c
+++ b/inet/ether_hton.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1999, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1999, 2002, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -71,7 +71,7 @@ ether_hostton (const char *hostname, struct ether_addr *addr)
status = (*fct.f) (hostname, &etherent, buffer, sizeof buffer, &errno);
- no_more = __nss_next (&nip, "gethostton_r", &fct.ptr, status, 0);
+ no_more = __nss_next2 (&nip, "gethostton_r", NULL, &fct.ptr, status, 0);
}
if (status == NSS_STATUS_SUCCESS)
diff --git a/inet/ether_line.c b/inet/ether_line.c
index 7e871a6bd7..13c5f394cf 100644
--- a/inet/ether_line.c
+++ b/inet/ether_line.c
@@ -61,19 +61,20 @@ ether_line (const char *line, struct ether_addr *addr, char *hostname)
++line;
}
- /* Remove trailing white space. */
- cp = __strchrnul (line, '#');
- while (cp > line && isspace (cp[-1]))
- --cp;
+ /* Skip initial whitespace. */
+ while (isspace (*line))
+ ++line;
- if (cp == line)
+ if (*line == '#' || *line == '\0')
/* No hostname. */
return -1;
+ /* The hostname is up to the next non-space character. */
/* XXX This can cause trouble because the hostname might be too long
but we have no possibility to check it here. */
- memcpy (hostname, line, cp - line);
- hostname [cp - line] = '\0';
+ while (*line != '\0' && *line != '#' && !isspace (*line))
+ *hostname++ = *line++;
+ *hostname = '\0';
return 0;
}
diff --git a/inet/ether_ntoh.c b/inet/ether_ntoh.c
index ad4165cb3e..9bc26b9fb6 100644
--- a/inet/ether_ntoh.c
+++ b/inet/ether_ntoh.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1999, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,1999,2001,2002,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -72,7 +72,7 @@ ether_ntohost (char *hostname, const struct ether_addr *addr)
status = (*fct.f) (addr, &etherent, buffer, sizeof buffer, &errno);
- no_more = __nss_next (&nip, "getntohost_r", &fct.ptr, status, 0);
+ no_more = __nss_next2 (&nip, "getntohost_r", NULL, &fct.ptr, status, 0);
}
if (status == NSS_STATUS_SUCCESS)
diff --git a/inet/gethstbyad_r.c b/inet/gethstbyad_r.c
index 020ac489ef..b1f0f496f1 100644
--- a/inet/gethstbyad_r.c
+++ b/inet/gethstbyad_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996,1997,1998,1999,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2000,2002,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -48,6 +48,6 @@
}
/* Special name for the lookup function. */
-#define DB_LOOKUP_FCT __nss_hosts_lookup
+#define DB_LOOKUP_FCT __nss_hosts_lookup2
#include "../nss/getXXbyYY_r.c"
diff --git a/inet/gethstbynm2_r.c b/inet/gethstbynm2_r.c
index e1e691b2b5..de33dfc93b 100644
--- a/inet/gethstbynm2_r.c
+++ b/inet/gethstbynm2_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2002, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -41,6 +41,6 @@
#define HAVE_AF 1
/* Special name for the lookup function. */
-#define DB_LOOKUP_FCT __nss_hosts_lookup
+#define DB_LOOKUP_FCT __nss_hosts_lookup2
#include "../nss/getXXbyYY_r.c"
diff --git a/inet/gethstbynm_r.c b/inet/gethstbynm_r.c
index 5bc65f1391..16cc194641 100644
--- a/inet/gethstbynm_r.c
+++ b/inet/gethstbynm_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2002, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -40,6 +40,6 @@
#define HAVE_LOOKUP_BUFFER 1
/* Special name for the lookup function. */
-#define DB_LOOKUP_FCT __nss_hosts_lookup
+#define DB_LOOKUP_FCT __nss_hosts_lookup2
#include "../nss/getXXbyYY_r.c"
diff --git a/inet/gethstent_r.c b/inet/gethstent_r.c
index a7424a4188..943cf04550 100644
--- a/inet/gethstent_r.c
+++ b/inet/gethstent_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 2002, 2007 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
@@ -30,6 +30,6 @@
#define NEED__RES 1
/* Special name for the lookup function. */
-#define DB_LOOKUP_FCT __nss_hosts_lookup
+#define DB_LOOKUP_FCT __nss_hosts_lookup2
#include "../nss/getXXent_r.c"
diff --git a/inet/getnetgrent_r.c b/inet/getnetgrent_r.c
index 97b2b809f0..38701857cb 100644
--- a/inet/getnetgrent_r.c
+++ b/inet/getnetgrent_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 1999, 2002, 2004, 2005
+/* Copyright (C) 1996, 1997, 1998, 1999, 2002, 2004, 2005, 2007
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -18,13 +18,16 @@
02111-1307 USA. */
#include <assert.h>
+#include <atomic.h>
#include <bits/libc-lock.h>
#include <errno.h>
#include <netdb.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "netgroup.h"
#include "nsswitch.h"
+#include <sysdep.h>
/* Protect above variable against multiple uses at the same time. */
@@ -44,25 +47,32 @@ static int
setup (void **fctp, service_user **nipp)
{
/* Remember the first service_entry, it's always the same. */
+ static bool startp_initialized;
static service_user *startp;
int no_more;
- if (startp == NULL)
+ if (!startp_initialized)
{
/* Executing this more than once at the same time must yield the
same result every time. So we need no locking. */
no_more = __nss_netgroup_lookup (nipp, "setnetgrent", fctp);
startp = no_more ? (service_user *) -1 : *nipp;
+ PTR_MANGLE (startp);
+ atomic_write_barrier ();
+ startp_initialized = true;
}
- else if (startp == (service_user *) -1)
- /* No services at all. */
- return 1;
else
{
+ service_user *nip = startp;
+ PTR_DEMANGLE (nip);
+ if (nip == (service_user *) -1)
+ /* No services at all. */
+ return 1;
+
/* Reset to the beginning of the service list. */
- *nipp = startp;
+ *nipp = nip;
/* Look up the first function. */
- no_more = __nss_lookup (nipp, "setnetgrent", fctp);
+ no_more = __nss_lookup (nipp, "setnetgrent", NULL, fctp);
}
return no_more;
}
@@ -122,11 +132,12 @@ __internal_setnetgrent_reuse (const char *group, struct __netgrent *datap,
{
assert (datap->data == NULL);
- /* Ignore status, we force check in `__nss_next'. */
+ /* Ignore status, we force check in `__nss_next2'. */
status = (*fct.f) (group, datap);
service_user *old_nip = datap->nip;
- no_more = __nss_next (&datap->nip, "setnetgrent", &fct.ptr, status, 0);
+ no_more = __nss_next2 (&datap->nip, "setnetgrent", NULL, &fct.ptr,
+ status, 0);
if (status == NSS_STATUS_SUCCESS && ! no_more)
{
@@ -423,8 +434,8 @@ innetgr (const char *netgroup, const char *host, const char *user,
break;
/* Look for the next service. */
- no_more = __nss_next (&entry.nip, "setnetgrent",
- &setfct.ptr, status, 0);
+ no_more = __nss_next2 (&entry.nip, "setnetgrent", NULL,
+ &setfct.ptr, status, 0);
}
if (result == 0 && entry.needed_groups != NULL)
diff --git a/inet/tst-ether_line.c b/inet/tst-ether_line.c
new file mode 100644
index 0000000000..ff0560b16a
--- /dev/null
+++ b/inet/tst-ether_line.c
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <string.h>
+#include <netinet/ether.h>
+
+
+static int
+do_test (void)
+{
+ struct ether_addr a;
+ char buf[1000];
+ if (ether_line ("00:01:02:03:04:05 aaaaa \n", &a, buf) != 0)
+ {
+ puts ("ether_line failed");
+ return 1;
+ }
+
+ int res = 0;
+ int i;
+ for (i = 0; i < ETH_ALEN; ++i)
+ {
+ printf ("%02x%s",
+ (int) a.ether_addr_octet[i], i + 1 == ETH_ALEN ? "" : ":");
+ if (a.ether_addr_octet[i] != i)
+ {
+ printf ("octet %d is %d, expected %d\n",
+ i, (int) a.ether_addr_octet[i], i);
+ res = 1;
+ }
+ }
+
+ printf (" \"%s\"\n", buf);
+ res |= strcmp (buf, "aaaaa") != 0;
+
+ return res;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"