Hi,
I am  100% sure that my  colleague  found fundamentals  of this bug.
On SPARC linux is used thread safe version of gethostbyname genthostbyname_r. This function have third argument char buffer. But if this buffer is not correctly aligned (on SPARC / 4 ) program crashed with BUSS ERROR. I attach demonstrate program to test this issue. If you change size of buffer from 1002 to 1000 program start working.
I mean  that simple workaround on SPARC is not use gethostbyname_r.

            Regards
                    Dan

--
Mydatex s r.o.
http://www.mydatex.cz
email: [EMAIL PROTECTED]
mob: 604200362
tel: 226210085
#include<stdio.h>
#include<netdb.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>

extern int h_errno;


int  main(void)
{

int ret;
const char *name="karotka";
char buf[1002];
int  tmp_errno,buflen;
struct hostent tmp_hostent,*hp;
//struct hostent_data hd;
int size;

buflen=1000;

//size=sizeof(struct hostent_data);
//printf("size=%d\n",size);

  
  printf("Align buff result=%p,buffer=%p,buflen=%d\n",&tmp_hostent,buf,buflen);

  ret=gethostbyname_r(name,&tmp_hostent, buf,buflen,&hp,&tmp_errno);  

  printf("ret:=%d\n",ret);
  if(ret==0)
  {
  
    if(hp)
    {
    
        printf("Lenght:=%d\n",hp->h_length);
        printf("Addr:=%X\n",hp->h_addr);
        printf("Name:=%s\n",hp->h_name);
        
    
    }
  
  
  }






 return(ret);
}

Reply via email to