Skip to content

Possible fd leak in session_client_tls.c #580

@rakichinni

Description

@rakichinni

Hi @michalvasko,

libnetconf2 version 4.4.2.

Scenario: If the CA cert at the netconf server is not a valid for netconf client. Establishing Netconf session using call-home with TLS ends up not closing fd.

Code snippet: nc_client_tls_session_new() in session_client_tls.c from line 294 to 324.

   sock = -1;
...
    while ((ret = nc_client_tls_handshake_step_wrap(tls_session, sock_tmp)) == 0) {
        usleep(NC_TIMEOUT_STEP);
        if ((timeout > -1) && (nc_timeouttime_cur_diff(&ts_timeout) < 1)) {
            ERR(NULL, "SSL connect timeout.");
            goto fail;
        }
    }

    /* check if handshake was ok */
    if (nc_client_tls_connect_check(ret, tls_session, host) != 1) {
        goto fail;
    }

    *out_tls_cfg = tls_cfg;
    return tls_session;

fail:
//************As the sock is set to -1 above. Flow will never enter inside _if_ block and sock is not closed.
    if (sock > -1) {
        close(sock);
    }

Please let us know if its a known issue.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:bugBug description.status:completedFrom the developer perspective, the issue was solved (bug fixed, question answered,...)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions