Bug 17132

Summary: bugs in xdr functions
Product: Base System Reporter: stda <stda>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description stda 2000-03-02 14:30:01 UTC
The implementation of xdr_*int64_t using xdr_opaque is not working
in intel environment.

Fix: 

/*
 * XDR 64-bit integers
 */
bool_t
xdr_int64_t (XDR *xdrs, int64_t *int64_p)
{
  long t1;
  unsigned long t2;

  switch(xdrs->x_op)
    {
    case XDR_ENCODE:
      t1 = (long) ((*int64_p) >> 32);
      t2 = (long) (*int64_p);
      return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2));
      break;
    case XDR_DECODE:
      if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2))
        return FALSE;
      *int64_p = ((int64_t) t1) << 32;
      *int64_p |= t2; /* needs unsigned type */
      return TRUE;
      break;
    case XDR_FREE:
      return TRUE;
      break;
    }
  return FALSE;
}


/*
 * XDR unsigned 64-bit integers
 */
bool_t
x_xdr_u_int64_t (XDR *xdrs, u_int64_t *uint64_p)
{
  unsigned long t1;
  unsigned long t2;

  switch(xdrs->x_op)
    {
    case XDR_ENCODE:
      t1 = (unsigned long) ((*uint64_p) >> 32);
      t2 = (unsigned long) (*uint64_p);
      return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2));
      break;
    case XDR_DECODE:
      if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2))
        return FALSE;
      *uint64_p = ((u_int64_t) t1) << 32;
      *uint64_p |= t2;
      return TRUE;
      break;
    case XDR_FREE:
      return TRUE;
      break;
    }
  return FALSE;
}
Comment 1 iedowse freebsd_committer freebsd_triage 2002-01-22 23:42:02 UTC
State Changed
From-To: open->closed


Fixed quite some time ago in both -STABLE and -CURRENT.