next test release (5th)

Jakub Jelinek jakub@redhat.com
Fri Sep 29 03:02:00 GMT 2000


On Fri, Sep 29, 2000 at 09:30:16AM +0200, Thorsten Kukuk wrote:
> The other problem I found is the nscd interface. It seems it is
> incompatible between 32bit and 64bit platforms. This will be a
> problem with all the upcoming platforms which support 32 and 64bit
> binaries. But I don't think that we need to solve it now. I even
> don't know where the problem is.

Ok, this is untested, I just wonder if it is the right way to go.
The issue is that nscd and its client send a lot of size_t and ssize_t data
over the socket, but those types differ between 32bit and 64bit.
>From quick look at what sizes and counts those entries represents it looks
to me like they'll always fit into 32 bits, I really cannot imagine system
with usernames 5GB long, or group names, hostnames, home directory pathnames
and the like. As we need to maintain nscd binary compatibility at least on
alpha, I have introduced new header which all architectures which will have 
dual wordsize libraries natively should override.

2000-09-29  Jakub Jelinek  <jakub@redhat.com>

	* nscd/nscd-client.h: Include nscd-types.h.
	Use nscd_ssize_t where appropriate.
	* sysdeps/generic/nscd-types.h: New file.
	* sysdeps/sparc/nscd-types.h: New file.
	* nscd/nscd_gethst_r.c (nscd_gethst_r): Use nscd_size_t where
	appropriate.
	* nscd/nscd_getgr_r.c (nscd_getgr_r): Likewise.
	* nscd/hstcache.c (cache_addhst): Likewise.
	* nscd/grpcache.c (cache_addgr): Likewise.

--- libc/nscd/nscd_gethst_r.c.jj	Wed May  3 10:19:59 2000
+++ libc/nscd/nscd_gethst_r.c	Fri Sep 29 11:30:57 2000
@@ -165,7 +165,7 @@ nscd_gethst_r (const char *key, size_t k
   if (hst_resp.found == 1)
     {
       struct iovec vec[4];
-      size_t *aliases_len;
+      nscd_size_t *aliases_len;
       char *cp = buffer;
       uintptr_t align1;
       uintptr_t align2;
@@ -206,12 +206,12 @@ nscd_gethst_r (const char *key, size_t k
       vec[0].iov_base = resultbuf->h_name;
       vec[0].iov_len = hst_resp.h_name_len;
 
-      aliases_len = alloca (hst_resp.h_aliases_cnt * sizeof (size_t));
+      aliases_len = alloca (hst_resp.h_aliases_cnt * sizeof (nscd_size_t));
       vec[1].iov_base = aliases_len;
-      vec[1].iov_len = hst_resp.h_aliases_cnt * sizeof (size_t);
+      vec[1].iov_len = hst_resp.h_aliases_cnt * sizeof (nscd_size_t);
 
       total_len = (hst_resp.h_name_len
-		   + hst_resp.h_aliases_cnt * sizeof (size_t));
+		   + hst_resp.h_aliases_cnt * sizeof (nscd_size_t));
 
       n = 2;
       if (type == GETHOSTBYADDR || type == GETHOSTBYNAME)
--- libc/nscd/hstcache.c.jj	Tue Mar 21 11:58:16 2000
+++ libc/nscd/hstcache.c	Fri Sep 29 11:32:13 2000
@@ -125,7 +125,7 @@ cache_addhst (struct database *db, int f
       struct hostdata *data;
       size_t h_name_len = strlen (hst->h_name) + 1;
       size_t h_aliases_cnt;
-      size_t *h_aliases_len;
+      nscd_size_t *h_aliases_len;
       size_t h_addr_list_cnt;
       int addr_list_type;
       char *addresses;
@@ -139,7 +139,7 @@ cache_addhst (struct database *db, int f
       for (cnt = 0; hst->h_aliases[cnt] != NULL; ++cnt)
 	++h_aliases_cnt;
       /* Determine the length of all aliases.  */
-      h_aliases_len = alloca (h_aliases_cnt * sizeof (size_t));
+      h_aliases_len = alloca (h_aliases_cnt * sizeof (nscd_size_t));
       total = 0;
       for (cnt = 0; cnt < h_aliases_cnt; ++cnt)
 	{
@@ -156,7 +156,7 @@ cache_addhst (struct database *db, int f
 	 the response header and the dataset itself.  */
       total += (sizeof (struct hostdata)
 		+ h_name_len
-		+ h_aliases_cnt * sizeof (size_t)
+		+ h_aliases_cnt * sizeof (nscd_size_t)
 		+ h_addr_list_cnt * hst->h_length);
 
       data = (struct hostdata *) malloc (total + req->key_len);
@@ -175,7 +175,7 @@ cache_addhst (struct database *db, int f
       cp = data->strdata;
 
       cp = mempcpy (cp, hst->h_name, h_name_len);
-      cp = mempcpy (cp, h_aliases_len, h_aliases_cnt * sizeof (size_t));
+      cp = mempcpy (cp, h_aliases_len, h_aliases_cnt * sizeof (nscd_size_t));
 
       /* The normal addresses first.  */
       addresses = cp;
--- libc/nscd/grpcache.c.jj	Wed May  3 10:19:59 2000
+++ libc/nscd/grpcache.c	Fri Sep 29 11:28:50 2000
@@ -117,7 +117,7 @@ cache_addgr (struct database *db, int fd
       size_t gr_name_len = strlen (grp->gr_name) + 1;
       size_t gr_passwd_len = strlen (grp->gr_passwd) + 1;
       size_t gr_mem_cnt = 0;
-      size_t *gr_mem_len;
+      nscd_size_t *gr_mem_len;
       size_t gr_mem_len_total = 0;
       char *gr_name;
       char *cp;
@@ -131,7 +131,7 @@ cache_addgr (struct database *db, int fd
       /* Determine the length of all members.  */
       while (grp->gr_mem[gr_mem_cnt])
 	++gr_mem_cnt;
-      gr_mem_len = (size_t *) alloca (gr_mem_cnt * sizeof (size_t));
+      gr_mem_len = (nscd_size_t *) alloca (gr_mem_cnt * sizeof (nscd_size_t));
       for (gr_mem_cnt = 0; grp->gr_mem[gr_mem_cnt]; ++gr_mem_cnt)
 	{
 	  gr_mem_len[gr_mem_cnt] = strlen (grp->gr_mem[gr_mem_cnt]) + 1;
@@ -141,7 +141,7 @@ cache_addgr (struct database *db, int fd
       /* We allocate all data in one memory block: the iov vector,
 	 the response header and the dataset itself.  */
       total = (sizeof (struct groupdata)
-	       + gr_mem_cnt * sizeof (size_t)
+	       + gr_mem_cnt * sizeof (nscd_size_t)
 	       + gr_name_len + gr_passwd_len + gr_mem_len_total);
       data = (struct groupdata *) malloc (total + n);
       if (data == NULL)
@@ -157,7 +157,7 @@ cache_addgr (struct database *db, int fd
       cp = data->strdata;
 
       /* This is the member string length array.  */
-      cp = mempcpy (cp, gr_mem_len, gr_mem_cnt * sizeof (size_t));
+      cp = mempcpy (cp, gr_mem_len, gr_mem_cnt * sizeof (nscd_size_t));
       gr_name = cp;
       cp = mempcpy (cp, grp->gr_name, gr_name_len);
       cp = mempcpy (cp, grp->gr_passwd, gr_passwd_len);
--- libc/nscd/nscd-client.h.jj	Mon Sep 27 02:20:13 1999
+++ libc/nscd/nscd-client.h	Fri Sep 29 11:51:46 2000
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (c) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
 
@@ -23,6 +23,8 @@
 #ifndef _NSCD_CLIENT_H
 #define _NSCD_CLIENT_H	1
 
+#include <nscd-types.h>
+
 /* Version number of the daemon interface */
 #define NSCD_VERSION 2
 
@@ -60,7 +62,7 @@ typedef struct
 {
   int version;		/* Version number of the daemon interface.  */
   request_type type;	/* Service requested.  */
-  ssize_t key_len;	/* Key length.  */
+  nscd_ssize_t key_len;	/* Key length.  */
 } request_header;
 
 
@@ -70,13 +72,13 @@ typedef struct
 {
   int version;
   int found;
-  ssize_t pw_name_len;
-  ssize_t pw_passwd_len;
+  nscd_ssize_t pw_name_len;
+  nscd_ssize_t pw_passwd_len;
   uid_t pw_uid;
   gid_t pw_gid;
-  ssize_t pw_gecos_len;
-  ssize_t pw_dir_len;
-  ssize_t pw_shell_len;
+  nscd_ssize_t pw_gecos_len;
+  nscd_ssize_t pw_dir_len;
+  nscd_ssize_t pw_shell_len;
 } pw_response_header;
 
 
@@ -86,10 +88,10 @@ typedef struct
 {
   int version;
   int found;
-  ssize_t gr_name_len;
-  ssize_t gr_passwd_len;
+  nscd_ssize_t gr_name_len;
+  nscd_ssize_t gr_passwd_len;
   gid_t gr_gid;
-  ssize_t gr_mem_cnt;
+  nscd_ssize_t gr_mem_cnt;
 } gr_response_header;
 
 
@@ -99,11 +101,11 @@ typedef struct
 {
   int version;
   int found;
-  ssize_t h_name_len;
-  ssize_t h_aliases_cnt;
+  nscd_ssize_t h_name_len;
+  nscd_ssize_t h_aliases_cnt;
   int h_addrtype;
   int h_length;
-  ssize_t h_addr_list_cnt;
+  nscd_ssize_t h_addr_list_cnt;
   int error;
 } hst_response_header;
 
--- libc/nscd/nscd_getgr_r.c.jj	Mon Sep  6 01:33:26 1999
+++ libc/nscd/nscd_getgr_r.c	Fri Sep 29 11:33:20 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@uni-paderborn.de>, 1998.
 
@@ -137,7 +137,7 @@ nscd_getgr_r (const char *key, size_t ke
 
   if (gr_resp.found == 1)
     {
-      size_t *len;
+      nscd_size_t *len;
       char *p = buffer;
       size_t total_len;
       uintptr_t align;
@@ -172,9 +172,9 @@ nscd_getgr_r (const char *key, size_t ke
       resultbuf->gr_gid = gr_resp.gr_gid;
 
       /* Allocate array to store lengths.  */
-      len = alloca (gr_resp.gr_mem_cnt * sizeof (size_t));
+      len = alloca (gr_resp.gr_mem_cnt * sizeof (nscd_size_t));
 
-      total_len = gr_resp.gr_mem_cnt * sizeof (size_t);
+      total_len = gr_resp.gr_mem_cnt * sizeof (nscd_size_t);
       vec[0].iov_base = len;
       vec[0].iov_len = total_len;
       vec[1].iov_base = resultbuf->gr_name;
--- libc/sysdeps/generic/nscd-types.h.jj	Fri Sep 29 11:36:00 2000
+++ libc/sysdeps/generic/nscd-types.h	Fri Sep 29 11:35:54 2000
@@ -0,0 +1,22 @@
+/* Copyright (C) 2000 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
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sys/types.h>
+
+typedef size_t nscd_size_t;
+typedef ssize_t nscd_ssize_t;
--- libc/sysdeps/sparc/nscd-types.h.jj	Fri Sep 29 11:36:00 2000
+++ libc/sysdeps/sparc/nscd-types.h	Fri Sep 29 11:45:16 2000
@@ -0,0 +1,24 @@
+/* Copyright (C) 2000 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
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sys/types.h>
+
+/* So that 32bit glibc can talk to 64bit nscd and vice versa, we need to
+   be binary compatible.  */
+typedef u_int32_t nscd_size_t;
+typedef int32_t nscd_ssize_t;


	Jakub


More information about the Libc-hacker mailing list