Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Mar 2000 06:22:02 -0800 (PST)
From:      stda@enea.se
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/17132: bugs in xdr functions
Message-ID:  <200003021422.GAA87383@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help


>Number:         17132
>Category:       misc
>Synopsis:       bugs in xdr functions
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar  2 06:30:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Sten Dahlgren
>Release:        3.2
>Organization:
Enead Data AB
>Environment:
FreeBSD whip.ose.enea.se 3.2-RELEASE FreeBSD 3.2-RELEASE #0: Thu Dec 16 18:12:00 CET 1999     bjsv@whip.ose.enea.se:/usr/src/sys/compile/WHIP  i386
>Description:
The implementation of xdr_*int64_t using xdr_opaque is not working
in intel environment. 
>How-To-Repeat:

>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;
}

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200003021422.GAA87383>