NetBSD Problem Report #1115
From gnats Mon Jun 5 04:07:08 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.10/8.6.10) with ESMTP id EAA28718 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Mon, 5 Jun 1995 04:07:07 -0700
Message-Id: <199506051108.HAA14536@Collatz.McRCIM.McGill.EDU>
Date: Mon, 5 Jun 1995 07:08:09 -0400
From: der Mouse <mouse@Collatz.McRCIM.McGill.EDU>
Reply-To: mouse@Collatz.McRCIM.McGill.EDU
To: gnats-bugs@netbsd.org
Subject: xdr_double broken on little-endians
X-Send-Pr-Version: 3.2
>Number: 1115
>Category: lib
>Synopsis: xdr_double broken on little-endians
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jun 05 04:20:03 +0000 1995
>Closed-Date: Tue Jun 27 21:02:57 +0000 1995
>Last-Modified:
>Originator: der Mouse
>Release: -current as of May 9th
>Organization:
Dis-
>Environment:
Any little-endian architecture using IEEE fp
>Description:
See Kent Vander Velden <graphix@iastate.edu>'s message to
current-users, Message-Id:
<9506050722.AA12708@spiff.cc.iastate.edu>, Subject: XDR and
double data type, Date: Mon, 05 Jun 1995 02:22:14 CDT.
Briefly, xdr_double() either mis-encodes or mis-decodes
doubles. Reading the code makes me think it's mis-encoding.
>How-To-Repeat:
(This is taken from the aforementioned letter; untested since I
have no little-endian NetBSD machine.)
#include <stdio.h>
#include <stdlib.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
int
main(void) {
double x=3.14159;
double y=0.0;
char *xdr_buffer=NULL;
XDR xdrs;
int nbytes=1024; /*sizeof(double);*/
xdr_buffer = (char*)malloc(nbytes);
xdrmem_create(&xdrs, xdr_buffer, nbytes, XDR_ENCODE);
xdr_double(&xdrs, &x);
xdr_destroy(&xdrs);
xdrmem_create(&xdrs, xdr_buffer, nbytes, XDR_DECODE);
xdr_double(&xdrs, &y);
xdr_destroy(&xdrs);
free(xdr_buffer);
printf("before encoding=%f\nafter encoding=%f\n", x, y);
return 0;
}
>Fix:
In lib/libc/rpc/xdr_float.c (line 233 in the copy I have) there
is the fragment
tmpl = *i32p+1;
rv = XDR_PUTLONG(xdrs, &tmpl);
if (!rv)
return (rv);
tmpl = *i32p;
rv = XDR_PUTLONG(xdrs, &tmpl);
From context, and from the parallel code in the XDR_DECODE
case, it's clear that *i32p+1 should be *(i32p+1), or perhaps
preferably i32p[1].
That code appears to have alignment problems too, which I
intend to investigate more fully and send-pr as appropriate.
der Mouse
mouse@collatz.mcrcim.mcgill.edu
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: jtc
State-Changed-When: Tue Jun 27 21:02:57 1995
State-Changed-Why:
Fixed by pk on Jun 6th.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.