Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/rpc When writing/reading longs use explicit 32bit t...



details:   https://anonhg.NetBSD.org/src/rev/246e6ec7689e
branches:  trunk
changeset: 557183:246e6ec7689e
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Jan 03 23:01:41 2004 +0000

description:
When writing/reading longs use explicit 32bit temporary values (this is
what "long" means in xdr context).
Fixes PR lib/23960.

diffstat:

 lib/libc/rpc/xdr_stdio.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (41 lines):

diff -r cd83b2694385 -r 246e6ec7689e lib/libc/rpc/xdr_stdio.c
--- a/lib/libc/rpc/xdr_stdio.c  Sat Jan 03 22:56:52 2004 +0000
+++ b/lib/libc/rpc/xdr_stdio.c  Sat Jan 03 23:01:41 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xdr_stdio.c,v 1.14 2000/01/22 22:19:19 mycroft Exp $   */
+/*     $NetBSD: xdr_stdio.c,v 1.15 2004/01/03 23:01:41 martin Exp $    */
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -35,7 +35,7 @@
 static char *sccsid = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)xdr_stdio.c 2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: xdr_stdio.c,v 1.14 2000/01/22 22:19:19 mycroft Exp $");
+__RCSID("$NetBSD: xdr_stdio.c,v 1.15 2004/01/03 23:01:41 martin Exp $");
 #endif
 #endif
 
@@ -119,10 +119,11 @@
        XDR *xdrs;
        long *lp;
 {
+       u_int32_t temp;
 
-       if (fread(lp, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
+       if (fread(&temp, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
                return (FALSE);
-       *lp = (long)ntohl((u_int32_t)*lp);
+       *lp = (long)ntohl(temp);
        return (TRUE);
 }
 
@@ -131,7 +132,7 @@
        XDR *xdrs;
        const long *lp;
 {
-       long mycopy = (long)htonl((u_int32_t)*lp);
+       int32_t mycopy = htonl((int32_t)*lp);
 
        if (fwrite(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
                return (FALSE);



Home | Main Index | Thread Index | Old Index