about summary refs log tree commit diff
path: root/nss
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2002-11-10 11:06:36 +0000
committerAndreas Jaeger <aj@suse.de>2002-11-10 11:06:36 +0000
commitfb776f3ef3b2b7eaf7e92305b8b2dc480f31f3ff (patch)
treeb6d3b7b6350601fbb8f6cbf8f820d25c0ab59cdb /nss
parent55c303acb873e478540042612f1028139454d4a4 (diff)
downloadglibc-fb776f3ef3b2b7eaf7e92305b8b2dc480f31f3ff.tar.gz
glibc-fb776f3ef3b2b7eaf7e92305b8b2dc480f31f3ff.tar.xz
glibc-fb776f3ef3b2b7eaf7e92305b8b2dc480f31f3ff.zip
* nss/getXXent.c (GETFUNC_NAME): Use union type to avoid strict
aliasing problem. 
* nss/getXXbyYY_r.c (INTERNAL): Likewise. 
* nss/getnssent_r.c (__nss_getent_r): Likewise. 
(__nss_setent): Likewise. 
(__nss_getent_r): Likewise. 
* inet/getnetgrent_r.c (innetgr): Likewise. 
(__internal_setnetgrent_reuse): Likewise. 
(internal_getnetgrent_r): Likewise. 
* inet/ether_hton.c (ether_hostton): Likewise. 
* inet/ether_ntoh.c (ether_ntohost): Likewise. 
* sunrpc/netname.c (netname2user): Likewise. 
* sunrpc/publickey.c (getpublickey): Likewise. 
(getsecretkey): Likewise.
Diffstat (limited to 'nss')
-rw-r--r--nss/getXXbyYY_r.c45
-rw-r--r--nss/getXXent.c8
-rw-r--r--nss/getnssent_r.c52
3 files changed, 65 insertions, 40 deletions
diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c
index ca81cf4c8f..5bb28f7141 100644
--- a/nss/getXXbyYY_r.c
+++ b/nss/getXXbyYY_r.c
@@ -32,30 +32,30 @@
 #endif
 /*******************************************************************\
 |* Here we assume several symbols to be defined:		   *|
-|* 								   *|
+|*								   *|
 |* LOOKUP_TYPE   - the return type of the function		   *|
-|* 								   *|
+|*								   *|
 |* FUNCTION_NAME - name of the non-reentrant function		   *|
-|* 								   *|
+|*								   *|
 |* DATABASE_NAME - name of the database the function accesses	   *|
 |*		   (e.g., host, services, ...)			   *|
-|* 								   *|
+|*								   *|
 |* ADD_PARAMS    - additional parameter, can vary in number	   *|
-|* 								   *|
+|*								   *|
 |* ADD_VARIABLES - names of additional parameter		   *|
-|* 								   *|
+|*								   *|
 |* Optionally the following vars can be defined:		   *|
-|* 								   *|
+|*								   *|
 |* NEED_H_ERRNO  - an extra parameter will be passed to point to   *|
 |*		   the global `h_errno' variable.		   *|
-|* 								   *|
+|*								   *|
 |* NEED__RES     - the global _res variable might be used so we	   *|
-|* 		   will have to initialize it if necessary	   *|
-|* 								   *|
+|*		   will have to initialize it if necessary	   *|
+|*								   *|
 |* PREPROCESS    - code run before anything else		   *|
-|* 								   *|
+|*								   *|
 |* POSTPROCESS   - code run after the lookup			   *|
-|* 								   *|
+|*								   *|
 \*******************************************************************/
 
 /* To make the real sources a bit prettier.  */
@@ -130,7 +130,12 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
   static service_user *startp;
   static lookup_function start_fct;
   service_user *nip;
-  lookup_function fct;
+  union
+  {
+    lookup_function l;
+    void *ptr;
+  } fct;
+
   int no_more;
   enum nss_status status = NSS_STATUS_UNAVAIL;
 #ifdef USE_NSCD
@@ -175,13 +180,13 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
 
   if (startp == NULL)
     {
-      no_more = DB_LOOKUP_FCT (&nip, REENTRANT_NAME_STRING, (void **) &fct);
+      no_more = DB_LOOKUP_FCT (&nip, REENTRANT_NAME_STRING, &fct.ptr);
       if (no_more)
 	startp = (service_user *) -1l;
       else
 	{
 	  startp = nip;
-	  start_fct = fct;
+	  start_fct = fct.l;
 
 #ifdef NEED__RES
 	  /* The resolver code will really be used so we have to
@@ -201,7 +206,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
     }
   else
     {
-      fct = start_fct;
+      fct.l = start_fct;
       no_more = (nip = startp) == (service_user *) -1l;
     }
 
@@ -211,8 +216,8 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
       any_service = true;
 #endif
 
-      status = DL_CALL_FCT (fct, (ADD_VARIABLES, resbuf, buffer, buflen,
-				   &errno H_ERRNO_VAR));
+      status = DL_CALL_FCT (fct.l, (ADD_VARIABLES, resbuf, buffer, buflen,
+				    &errno H_ERRNO_VAR));
 
       /* The status is NSS_STATUS_TRYAGAIN and errno is ERANGE the
 	 provided buffer is too small.  In this case we should give
@@ -227,7 +232,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
 	break;
 
       no_more = __nss_next (&nip, REENTRANT_NAME_STRING,
-			    (void **) &fct, status, 0);
+			    &fct.ptr, status, 0);
     }
 
 #ifdef HANDLE_DIGITS_DOTS
@@ -262,7 +267,7 @@ OLD (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer,
 		      size_t buflen, LOOKUP_TYPE **result H_ERRNO_PARM)
 {
   int ret = INTERNAL (REENTRANT_NAME) (ADD_VARIABLES, resbuf, buffer,
-  				       buflen, result H_ERRNO_VAR);
+				       buflen, result H_ERRNO_VAR);
 
   if (ret != 0)
     ret = -1;
diff --git a/nss/getXXent.c b/nss/getXXent.c
index ebe6fff5f0..0a13b79d87 100644
--- a/nss/getXXent.c
+++ b/nss/getXXent.c
@@ -70,7 +70,11 @@ LOOKUP_TYPE *
 GETFUNC_NAME (void)
 {
   static size_t buffer_size;
-  static LOOKUP_TYPE resbuf;
+  static union
+  {
+    LOOKUP_TYPE l;
+    void *ptr;
+  } resbuf;
   LOOKUP_TYPE *result;
   int save;
 
@@ -79,7 +83,7 @@ GETFUNC_NAME (void)
 
   result = (LOOKUP_TYPE *)
     __nss_getent ((getent_r_function) INTERNAL (REENTRANT_GETNAME),
-		  (void **) &resbuf, &buffer, BUFLEN, &buffer_size,
+		  &resbuf.ptr, &buffer, BUFLEN, &buffer_size,
 		  H_ERRNO_VAR);
 
   save = errno;
diff --git a/nss/getnssent_r.c b/nss/getnssent_r.c
index c1f8965363..7545b80c4a 100644
--- a/nss/getnssent_r.c
+++ b/nss/getnssent_r.c
@@ -53,7 +53,11 @@ __nss_setent (const char *func_name, db_lookup_function lookup_fct,
 	      service_user **last_nip, int stayopen, int *stayopen_tmp,
 	      int res)
 {
-  setent_function fct;
+  union
+  {
+    setent_function f;
+    void *ptr;
+  } fct;
   int no_more;
 
   if (res && (_res.options & RES_INIT) == 0
@@ -65,7 +69,7 @@ __nss_setent (const char *func_name, db_lookup_function lookup_fct,
 
   /* Cycle through the services and run their `setXXent' functions until
      we find an available service.  */
-  no_more = setup (func_name, lookup_fct, (void **) &fct, nip,
+  no_more = setup (func_name, lookup_fct, &fct.ptr, nip,
 		   startp, 1);
   while (! no_more)
     {
@@ -73,11 +77,11 @@ __nss_setent (const char *func_name, db_lookup_function lookup_fct,
       enum nss_status status;
 
       if (stayopen_tmp)
-	status = DL_CALL_FCT (fct, (*stayopen_tmp));
+	status = DL_CALL_FCT (fct.f, (*stayopen_tmp));
       else
-	status = DL_CALL_FCT (fct, (0));
+	status = DL_CALL_FCT (fct.f, (0));
 
-      no_more = __nss_next (nip, func_name, (void **) &fct,
+      no_more = __nss_next (nip, func_name, &fct.ptr,
 			    status, 0);
       if (is_last_nip)
 	*last_nip = *nip;
@@ -93,7 +97,11 @@ __nss_endent (const char *func_name, db_lookup_function lookup_fct,
 	      service_user **nip, service_user **startp,
 	      service_user **last_nip, int res)
 {
-  endent_function fct;
+  union
+  {
+    endent_function f;
+    void *ptr;
+  } fct;
   int no_more;
 
   if (res && (_res.options & RES_INIT) == 0
@@ -104,17 +112,17 @@ __nss_endent (const char *func_name, db_lookup_function lookup_fct,
     }
 
   /* Cycle through all the services and run their endXXent functions.  */
-  no_more = setup (func_name, lookup_fct, (void **) &fct, nip, startp, 1);
+  no_more = setup (func_name, lookup_fct, &fct.ptr, nip, startp, 1);
   while (! no_more)
     {
       /* Ignore status, we force check in __NSS_NEXT.  */
-      DL_CALL_FCT (fct, ());
+      DL_CALL_FCT (fct.f, ());
 
       if (*nip == *last_nip)
 	/* We have processed all services which were used.  */
 	break;
 
-      no_more = __nss_next (nip, func_name, (void **) &fct, 0, 1);
+      no_more = __nss_next (nip, func_name, &fct.ptr, 0, 1);
     }
   *last_nip = *nip = NULL;
 }
@@ -129,7 +137,11 @@ __nss_getent_r (const char *getent_func_name,
 		void *resbuf, char *buffer, size_t buflen,
 		void **result, int *h_errnop)
 {
-  getent_function fct;
+  union
+  {
+    getent_function f;
+    void *ptr;
+  } fct;
   int no_more;
   enum nss_status status;
 
@@ -147,14 +159,14 @@ __nss_getent_r (const char *getent_func_name,
   /* Run through available functions, starting with the same function last
      run.  We will repeat each function as long as it succeeds, and then go
      on to the next service action.  */
-  no_more = setup (getent_func_name, lookup_fct, (void **) &fct, nip,
+  no_more = setup (getent_func_name, lookup_fct, &fct.ptr, nip,
 		   startp, 0);
   while (! no_more)
     {
       int is_last_nip = *nip == *last_nip;
 
-      status = DL_CALL_FCT (fct,
-			     (resbuf, buffer, buflen, &errno, &h_errno));
+      status = DL_CALL_FCT (fct.f,
+			    (resbuf, buffer, buflen, &errno, &h_errno));
 
       /* The the status is NSS_STATUS_TRYAGAIN and errno is ERANGE the
 	 provided buffer is too small.  In this case we should give
@@ -168,7 +180,7 @@ __nss_getent_r (const char *getent_func_name,
 
       do
 	{
-	  no_more = __nss_next (nip, getent_func_name, (void **) &fct,
+	  no_more = __nss_next (nip, getent_func_name, &fct.ptr,
 				status, 0);
 
 	  if (is_last_nip)
@@ -177,17 +189,21 @@ __nss_getent_r (const char *getent_func_name,
 	  if (! no_more)
 	    {
 	      /* Call the `setXXent' function.  This wasn't done before.  */
-	      setent_function sfct;
+	      union
+	      {
+		setent_function f;
+		void *ptr;
+	      } sfct;
 
 	      no_more = __nss_lookup (nip, setent_func_name,
-				      (void **) &sfct);
+				      &sfct.ptr);
 
 	      if (! no_more)
 	        {
 		  if (stayopen_tmp)
-		    status = DL_CALL_FCT (sfct, (*stayopen_tmp));
+		    status = DL_CALL_FCT (sfct.f, (*stayopen_tmp));
 		  else
-		    status = DL_CALL_FCT (sfct, (0));
+		    status = DL_CALL_FCT (sfct.f, (0));
 		}
 	      else
 		status = NSS_STATUS_NOTFOUND;