Subject: Select (function _libssh2_wait_socket) issue on some on an embedded platform

Select (function _libssh2_wait_socket) issue on some on an embedded platform

From: Sebastien Fricker <>
Date: Fri, 26 Mar 2010 11:54:25 +0100

we have found an issue on a real-time OS (here RTOS-32 from OnTime)
about the usage of select.

In the function _libssh_wait_socket select is used with 2 pointer of
descriptors: readfd and writefd.
This pointers are pointing to the same fd_set.
On RTOS32, this causes an error.

If readfd and writefd are pointing to 2 different variables, select
works well.

In this case the modified code would be:
int _libssh2_wait_socket(LIBSSH2_SESSION *session)
    fd_set fd_read;
    fd_set fd_write;
    fd_set *writefd = NULL;
    fd_set *readfd = NULL;
    int dir;
    int rc;

    FD_SET(session->socket_fd, &fd_read);
    FD_SET(session->socket_fd, &fd_write);

    /* now make sure we wait in the correct direction */
    dir = libssh2_session_block_directions(session);

        readfd = &fd_read;

        writefd = &fd_write;


The modification should not create any regression to libssh2, and if
nobody are seeing any problem about this code, I will provide a patch.

Ipetronik GmbH & Co.KG
Jaegerweg 1
D-76532 Baden-Baden
Phone-No. +49 - (0)7221/9922-467
Fax-No. +49 - (0)7221/9922-153
Kommanditgesellschaft mit Sitz in Baden-Baden, Registergericht HRA
Persoenlich haftende Gesellschaft ist die IPETRONIK Verwaltungs GmbH 
mit Sitz in Baden-Baden, Registergericht Mannheim HRB Nr.202089, 
Geschäftsführer: J.Abromeit, E.Rudolf, A. Wocke
Received on 2010-03-26