Skip to content

Commit a4c7911

Browse files
committed
ssh-libssh: fix infinite connect loop on invalid private key
Added test 656 (based on test 604) to verify the fix. Bug: https://bugzilla.redhat.com/1595135 Closes #2879
1 parent 1e843a3 commit a4c7911

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

lib/ssh-libssh.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block)
663663
if(rc != SSH_OK) {
664664
failf(data, "Could not load private key file %s",
665665
data->set.str[STRING_SSH_PRIVATE_KEY]);
666+
MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
666667
break;
667668
}
668669

tests/data/Makefile.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ test617 test618 test619 test620 test621 test622 test623 test624 test625 \
8383
test626 test627 test628 test629 test630 test631 test632 test633 test634 \
8484
test635 test636 test637 test638 test639 test640 test641 test642 \
8585
test643 test644 test645 test646 test647 test648 test649 test650 test651 \
86-
test652 test653 test654 test655 \
86+
test652 test653 test654 test655 test656 \
8787
\
8888
test700 test701 test702 test703 test704 test705 test706 test707 test708 \
8989
test709 test710 test711 test712 test713 test714 test715 \

tests/data/test656

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<testcase>
2+
<info>
3+
<keywords>
4+
SFTP
5+
FAILURE
6+
</keywords>
7+
</info>
8+
9+
#
10+
# Client-side
11+
<client>
12+
<server>
13+
sftp
14+
</server>
15+
<name>
16+
SFTP retrieval with nonexistent private key file
17+
</name>
18+
<command>
19+
--key DOES_NOT_EXIST --pubkey curl_client_key.pub -u %USER: sftp://%HOSTIP:%SSHPORT%PWD/not-a-valid-file-moooo --insecure --connect-timeout 8
20+
</command>
21+
</client>
22+
23+
#
24+
# Verify data after the test has been "shot"
25+
<verify>
26+
<valgrind>
27+
disable
28+
</valgrind>
29+
<errorcode>
30+
67
31+
</errorcode>
32+
</verify>
33+
</testcase>

0 commit comments

Comments
 (0)