Hello,
I develop a secure stack. This stack is between TCP and an application. The
appli call my stack's functions ( my_connect( ), my_listen( ), etc. ). I
have got segmentation fault after launching the the program.

SERVER SIDE :

my_recv( ) is like this :

int my_recv(my_cn sd, char* buf,  size_t* len, unsigned int flags, unsigned
int timeout){
    ...
    err = SSL_read(si->ssl, buf, *len);
    switch(err) {
          ...
    }
}

I call my_recv( ) in main( ) like this :

main( ){
    ...
    lsock =  my_listen(0, TESTPORT, test_proto, 5); // that's OK
    my_cn s2 = my_accept(lsock, &addr, &port); // That's OK
    ...
    char buf[10];
    size_t  len = 5;
    my_recv(s2, buf, &len, 0, 0); // Here is seg fault
    ...
}

After a simple debug ( only in server side) , I realized that:
1) seg fault is caused by SSL_read( )
2) si->ssl  != NULL

CLIENT SIDE :
maint( ) {
    my_cn sock = my_connect(inet_addr("127.0.0.1"), TESTPORT, &local_addr,
&local_port, test_proto); // That's OK
    my_send(sock, "Test", 5); // it fails ( seg fault here ... ? );
    ...
}

I am wondering what would cause the problem, probably buf or len...!? I
tried char buf[5] but I have got the same result.

Does someone find what happens.

Thanks

Reply via email to