Skip to content

Commit 9c6d38c

Browse files
committed
session BUGFIX do not communicate on invalid sessions
1 parent 0272dc3 commit 9c6d38c

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/session.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,12 +683,12 @@ nc_session_free(struct nc_session *session, void (*data_free)(void *))
683683
nc_session_client_msgs_unlock(session, __func__);
684684
}
685685

686-
/* receive any leftover messages */
687-
while (nc_read_msg_poll_io(session, 0, &msg) == 1) {
688-
ly_in_free(msg, 1);
689-
}
690-
691686
if (session->status == NC_STATUS_RUNNING) {
687+
/* receive any leftover messages */
688+
while (nc_read_msg_poll_io(session, 0, &msg) == 1) {
689+
ly_in_free(msg, 1);
690+
}
691+
692692
/* send closing info to the other side */
693693
ietfnc = ly_ctx_get_module_implemented(session->ctx, "ietf-netconf");
694694
if (!ietfnc) {

tests/client/test_client_ssh.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,6 @@ test_nc_connect_connection_failed(void **state)
628628
errno = ECONNREFUSED;
629629
will_return(__wrap_connect, -1);
630630
will_return(__wrap_ssh_is_connected, 0);
631-
will_return(__wrap_ssh_channel_poll_timeout, 0);
632631

633632
session = nc_connect_ssh("127.0.0.1", 8080, NULL);
634633
assert_null(session);
@@ -658,7 +657,6 @@ test_nc_connect_ssh_bad_hello(void **state)
658657
will_return(__wrap_ssh_channel_open_session, 0);
659658
will_return(__wrap_ssh_channel_request_subsystem, 0);
660659
will_return(__wrap_nc_handshake_io, 4);
661-
will_return(__wrap_ssh_channel_poll_timeout, 0);
662660

663661
session = nc_connect_ssh("127.0.0.1", 8080, NULL);
664662
assert_null(session);

0 commit comments

Comments
 (0)