Repository navigation
Conversation
Seen in CI when Libgcrypt could not negotiate keys with modern sshd
server on Ubuntu 26.04:
```
26: 1..2
26: Failure establishing SSH session: -5
26: Fingerprint: /home/REPOROOT/tests/test_sshd.test: line 151: 8233 Segmentation fault (core dumped) ${LIBSSH2_TEST_EXE_RUNNER:-} "${test}"
26: not ok 1 - sshd-test_ssh2
26: libssh2_session_handshake failed (-5): Unable to exchange encryption keys
```
Ref: https://github.com/libssh2/libssh2/actions/runs/28605810600/job/84825600948?pr=2174
Ref: libssh2#2174
```
/home/runner/work/libssh2/libssh2/example/scp_write.c:177:17: error: File position of the stream might be 'indeterminate' after a failed operation. Can cause undefined behavior [clang-analyzer-unix.Stream,-warnings-as-errors]
177 | nread = fread(mem, 1, sizeof(mem), local);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:61:8: note: Assuming 'rc' is 0
61 | if(rc) {
| ^~
/home/runner/work/libssh2/libssh2/example/scp_write.c:61:5: note: Taking false branch
61 | if(rc) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:67:8: note: Assuming 'argc' is <= 1
67 | if(argc > 1)
| ^~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:67:5: note: Taking false branch
67 | if(argc > 1)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:71:8: note: 'argc' is <= 2
71 | if(argc > 2)
| ^~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:71:5: note: Taking false branch
71 | if(argc > 2)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:73:8: note: 'argc' is <= 3
73 | if(argc > 3)
| ^~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:73:5: note: Taking false branch
73 | if(argc > 3)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:75:8: note: 'argc' is <= 4
75 | if(argc > 4)
| ^~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:75:5: note: Taking false branch
75 | if(argc > 4)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:77:8: note: 'argc' is <= 5
77 | if(argc > 5)
| ^~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:77:5: note: Taking false branch
77 | if(argc > 5)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:81:8: note: Assuming 'rc' is 0
81 | if(rc) {
| ^~
/home/runner/work/libssh2/libssh2/example/scp_write.c:81:5: note: Taking false branch
81 | if(rc) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:87:9: note: 'local' is non-null
87 | if(!local) {
| ^~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:87:5: note: Taking false branch
87 | if(!local) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:92:8: note: Assuming the condition is false
92 | if(fstat(fileno(local), &fileinfo)) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:30:15: note: expanded from macro 'fstat'
30 | #define fstat _fstat
| ^
/usr/x86_64-w64-mingw32/include/_mingw_stat64.h:14:16: note: expanded from macro '_fstat'
14 | #define _fstat _fstat64i32
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:92:5: note: Taking false branch
92 | if(fstat(fileno(local), &fileinfo)) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:102:8: note: Assuming the condition is false
102 | if(sock == LIBSSH2_INVALID_SOCKET) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:102:5: note: Taking false branch
102 | if(sock == LIBSSH2_INVALID_SOCKET) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:110:8: note: Assuming the condition is false
110 | if(connect(sock, (struct sockaddr *)(&sin), sizeof(struct sockaddr_in))) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:110:5: note: Taking false branch
110 | if(connect(sock, (struct sockaddr *)(&sin), sizeof(struct sockaddr_in))) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:117:8: note: Assuming 'session' is non-null
117 | if(!session) {
| ^~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:117:5: note: Taking false branch
117 | if(!session) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:126:8: note: Assuming 'rc' is 0
126 | if(rc) {
| ^~
/home/runner/work/libssh2/libssh2/example/scp_write.c:126:5: note: Taking false branch
126 | if(rc) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:138:8: note: Assuming 'fingerprint' is null
138 | if(!fingerprint)
| ^~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:138:5: note: Taking true branch
138 | if(!fingerprint)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:145:8: note: 'auth_pw' is 1
145 | if(auth_pw) {
| ^~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:145:5: note: Taking true branch
145 | if(auth_pw) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:147:12: note: Assuming the condition is false
147 | if(libssh2_userauth_password(session, username, password)) {
| ^
/home/runner/work/libssh2/libssh2/include/libssh2.h:674:5: note: expanded from macro 'libssh2_userauth_password'
674 | libssh2_userauth_password_ex(session, username, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
675 | (unsigned int)strlen(username), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
676 | password, (unsigned int)strlen(password), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
677 | NULL)
| ~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:147:9: note: Taking false branch
147 | if(libssh2_userauth_password(session, username, password)) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:166:8: note: Assuming 'channel' is non-null
166 | if(!channel) {
| ^~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:166:5: note: Taking false branch
166 | if(!channel) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:177:17: note: Assuming this stream operation fails
177 | nread = fread(mem, 1, sizeof(mem), local);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:178:12: note: Assuming 'nread' is > 0
178 | if(nread <= 0)
| ^~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:178:9: note: Taking false branch
178 | if(nread <= 0)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:186:16: note: Assuming 'nwritten' is < 0
186 | if(nwritten < 0) {
| ^~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:186:13: note: Taking true branch
186 | if(nwritten < 0) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:188:17: note: Execution continues on line 176
188 | break;
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:176:5: note: Loop condition is true. Execution continues on line 177
176 | do {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:177:17: note: File position of the stream might be 'indeterminate' after a failed operation. Can cause undefined behavior
177 | nread = fread(mem, 1, sizeof(mem), local);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:177:17: error: Read function called when stream is in EOF state. Function has no effect [clang-analyzer-unix.Stream,-warnings-as-errors]
177 | nread = fread(mem, 1, sizeof(mem), local);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:61:8: note: Assuming 'rc' is 0
61 | if(rc) {
| ^~
/home/runner/work/libssh2/libssh2/example/scp_write.c:61:5: note: Taking false branch
61 | if(rc) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:67:8: note: Assuming 'argc' is <= 1
67 | if(argc > 1)
| ^~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:67:5: note: Taking false branch
67 | if(argc > 1)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:71:8: note: 'argc' is <= 2
71 | if(argc > 2)
| ^~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:71:5: note: Taking false branch
71 | if(argc > 2)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:73:8: note: 'argc' is <= 3
73 | if(argc > 3)
| ^~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:73:5: note: Taking false branch
73 | if(argc > 3)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:75:8: note: 'argc' is <= 4
75 | if(argc > 4)
| ^~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:75:5: note: Taking false branch
75 | if(argc > 4)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:77:8: note: 'argc' is <= 5
77 | if(argc > 5)
| ^~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:77:5: note: Taking false branch
77 | if(argc > 5)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:81:8: note: Assuming 'rc' is 0
81 | if(rc) {
| ^~
/home/runner/work/libssh2/libssh2/example/scp_write.c:81:5: note: Taking false branch
81 | if(rc) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:87:9: note: 'local' is non-null
87 | if(!local) {
| ^~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:87:5: note: Taking false branch
87 | if(!local) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:92:8: note: Assuming the condition is false
92 | if(fstat(fileno(local), &fileinfo)) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:30:15: note: expanded from macro 'fstat'
30 | #define fstat _fstat
| ^
/usr/x86_64-w64-mingw32/include/_mingw_stat64.h:14:16: note: expanded from macro '_fstat'
14 | #define _fstat _fstat64i32
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:92:5: note: Taking false branch
92 | if(fstat(fileno(local), &fileinfo)) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:102:8: note: Assuming the condition is false
102 | if(sock == LIBSSH2_INVALID_SOCKET) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:102:5: note: Taking false branch
102 | if(sock == LIBSSH2_INVALID_SOCKET) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:110:8: note: Assuming the condition is false
110 | if(connect(sock, (struct sockaddr *)(&sin), sizeof(struct sockaddr_in))) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:110:5: note: Taking false branch
110 | if(connect(sock, (struct sockaddr *)(&sin), sizeof(struct sockaddr_in))) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:117:8: note: Assuming 'session' is non-null
117 | if(!session) {
| ^~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:117:5: note: Taking false branch
117 | if(!session) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:126:8: note: Assuming 'rc' is 0
126 | if(rc) {
| ^~
/home/runner/work/libssh2/libssh2/example/scp_write.c:126:5: note: Taking false branch
126 | if(rc) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:138:8: note: Assuming 'fingerprint' is null
138 | if(!fingerprint)
| ^~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:138:5: note: Taking true branch
138 | if(!fingerprint)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:145:8: note: 'auth_pw' is 1
145 | if(auth_pw) {
| ^~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:145:5: note: Taking true branch
145 | if(auth_pw) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:147:12: note: Assuming the condition is false
147 | if(libssh2_userauth_password(session, username, password)) {
| ^
/home/runner/work/libssh2/libssh2/include/libssh2.h:674:5: note: expanded from macro 'libssh2_userauth_password'
674 | libssh2_userauth_password_ex(session, username, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
675 | (unsigned int)strlen(username), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
676 | password, (unsigned int)strlen(password), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
677 | NULL)
| ~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:147:9: note: Taking false branch
147 | if(libssh2_userauth_password(session, username, password)) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:166:8: note: Assuming 'channel' is non-null
166 | if(!channel) {
| ^~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:166:5: note: Taking false branch
166 | if(!channel) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:177:17: note: Assuming stream reaches end-of-file here
177 | nread = fread(mem, 1, sizeof(mem), local);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:178:12: note: Assuming 'nread' is > 0
178 | if(nread <= 0)
| ^~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:178:9: note: Taking false branch
178 | if(nread <= 0)
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:186:16: note: Assuming 'nwritten' is < 0
186 | if(nwritten < 0) {
| ^~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/example/scp_write.c:186:13: note: Taking true branch
186 | if(nwritten < 0) {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:188:17: note: Execution continues on line 176
188 | break;
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:176:5: note: Loop condition is true. Execution continues on line 177
176 | do {
| ^
/home/runner/work/libssh2/libssh2/example/scp_write.c:177:17: note: Read function called when stream is in EOF state. Function has no effect
177 | nread = fread(mem, 1, sizeof(mem), local);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110 warnings generated.
```
https://github.com/libssh2/libssh2/actions/runs/28608272287/job/84834004928?pr=2179
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also bail out right away to avoid other issues down the line.
Seen in CI when Libgcrypt could not negotiate keys with modern sshd
server on Ubuntu 26.04:
Ref: https://github.com/libssh2/libssh2/actions/runs/28582866680/job/84747161004?pr=2174
Ref: #2174
IIRC this was also reported by GH Code Quality or Copilot earlier somewhere.