Bug 92889

Summary: [libc] xdr double buffer overflow
Product: Base System Reporter: Menshutin Anton <may>
Component: amd64Assignee: freebsd-amd64 (Nobody) <amd64>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Menshutin Anton 2006-02-06 13:00:14 UTC
Problem in xdr functions from libc on amd64. Sending doubles or floats
with pvm library causes out of range access in receiving program. First
4 bytes of double are being received correctly (when sending from i386
machine) but the last 4 bytes come to the wrong place, owerwriting 4 bytes
memory AFTER the double. Seems to be a problem with libc xdr packing/
unpacking functions.

How-To-Repeat: Write a simple test program sending double from one host to another.           

//test_pvm.c
#include <stdio.h>
#include "pvm3.h"
char *hostname="localhost"; //hostname where to run slave
char buf[1024];
int main()
{
  int tid;
  pvm_catchout(stdout);
  pvm_spawn("test_pvm_slave",NULL,PvmTaskHost,
      hostname,1,&tid);
  pvm_initsend(PvmDataDefault);
  double t=0.123;
  double *p;
  int i;
  unsigned int k;
  p=buf;
  *p=t;
  printf("Data before sending:");
  for (i=0;i<16;i++)
  {
    printf("%hhu ",buf[i]);
  }
  printf("\n");
  pvm_pkdouble(p,1,1);
  pvm_send(tid,0);
  pvm_exit();
  return(0);
}
//test_pvm_slave.c
#include "pvm3.h"
#include <stdio.h>
char buf[1024];
int main()
{
  int tid;
  double t=0.123;
  double *p;
  int i;
  fprintf(stderr,"I am slave\n");
  pvm_recv(pvm_parent(),0);
  p=buf;
  pvm_upkdouble(p,1,1);
  t=*p;
  for (i=0;i<16;i++)
  {
    printf("%hhu ",buf[i]);
  }
  printf("\n");
  pvm_exit();
  return(0);
}
Comment 1 Nate Eldredge 2007-10-17 04:18:37 UTC
I cannot reproduce this.  I'm using pvm-3.4.5_2 from ports.  I couldn't 
figure out how to run the master and slave on the same machine, so I ran 
the master on an i386 Linux box (debian unstable, with pvm 3.4.5-9) and 
the slave on FreeBSD 6.2-RELEASE-p7/amd64, and master and slave produce 
the same output.  I also tried sending the data the other way with the 
same result.

-- 
Nate Eldredge
nge@cs.hmc.edu
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2008-05-05 02:54:22 UTC
State Changed
From-To: open->feedback

Note that submitter was asked for feedback quite some time ago.
Comment 3 Menshutin Anton 2008-05-09 10:09:37 UTC
This bug seems to be already resolved. I tested it under 6.2 and 7.0 and 
everything seems to be ok now.
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2008-05-09 15:46:33 UTC
State Changed
From-To: feedback->closed

Submitter says that this is now fixed.