Repository navigation
Conversation
|
Forgot to add that file I guess? |
|
yes, sorry! |
|
should be fixed. |
|
Yes, works now. Now I just ran into problems with the configure script. Not really your fault as you just used the same style already used, its just that it isn't very good... |
|
I suppose I'm gonna have to build mbedtls from source on travis. I had hoped that wasn't necessary anymore since we don't need to patch it now, but it looks like Travis' ubuntu is too old to have the package and I couldn't find a good ppa. |
|
Thanks for all the work. I merged what we have now. For follow up fixes and more, just create new issues or PRs, thanks! |
|
Fantastic, thank you so much @bagder! |
|
Ah right, we need to fix the travis build. Do we revert the commit 3e6de50 to start with or do you have a fix pending? |
|
I'll try a PR |
linux (clang-tidy, amd64, mbedTLS-prev, cmake, ON):
```
/home/runner/work/libssh2/libssh2/src/mbedtls.c:744:8: error: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch,-warnings-as-errors]
744 | if(ret) {
| ^
/home/runner/work/libssh2/libssh2/src/mbedtls.c:777:8: note: Assuming 'ret' is 0
777 | if(ret) {
| ^~~
/home/runner/work/libssh2/libssh2/src/mbedtls.c:777:5: note: Taking false branch
777 | if(ret) {
| ^
/home/runner/work/libssh2/libssh2/src/mbedtls.c:783:11: note: Calling '_libssh2_mbedtls_pub_priv_key'
783 | ret = _libssh2_mbedtls_pub_priv_key(session, method, method_len,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
784 | pubkeydata, pubkeydata_len, &pkey);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/src/mbedtls.c:718:5: note: 'ret' declared without an initial value
718 | int ret;
| ^~~~~~~
/home/runner/work/libssh2/libssh2/src/mbedtls.c:721:8: note: Assuming the condition is false
721 | if(mbedtls_pk_get_type(pkey) != MBEDTLS_PK_RSA) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/runner/work/libssh2/libssh2/src/mbedtls.c:721:5: note: Taking false branch
721 | if(mbedtls_pk_get_type(pkey) != MBEDTLS_PK_RSA) {
| ^
/home/runner/work/libssh2/libssh2/src/mbedtls.c:730:8: note: Assuming 'mth' is non-null
730 | if(mth) {
| ^~~
/home/runner/work/libssh2/libssh2/src/mbedtls.c:730:5: note: Taking true branch
730 | if(mth) {
| ^
/home/runner/work/libssh2/libssh2/src/mbedtls.c:739:9: note: 'key' is non-null
739 | if(!key) {
| ^~~
/home/runner/work/libssh2/libssh2/src/mbedtls.c:739:5: note: Taking false branch
739 | if(!key) {
| ^
/home/runner/work/libssh2/libssh2/src/mbedtls.c:744:8: note: Branch condition evaluates to a garbage value
744 | if(ret) {
| ^~~
4 warnings generated.
```
https://github.com/libssh2/libssh2/actions/runs/18620615649/job/53091295760#step:22:44
Follow-up to 186f1a2 libssh2#132
In `_libssh2_mbedtls_pub_priv_key()` on a NON-error code path, a stack
variable was checked without initializing it first.
I found it interesting that clang-tidy did not find this when building
against the system mbedtls (2.x) with 2.x compatibility code still it.
Then it did find it when using a manual build of mbedtls 3.1.0 with
2.x compatibility code deleted from libssh2. Being such a trivial error
I wonder why no compiler ever detected it as a regular warning.
linux (clang-tidy, amd64, mbedTLS-prev [3.1.0], cmake, ON):
```
/home/runner/work/libssh2/libssh2/src/mbedtls.c:744:8: error: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch,-warnings-as-errors]
744 | if(ret) {
| ^
```
Ref: https://github.com/libssh2/libssh2/actions/runs/18620615649/job/53091295760#step:22:44
Follow-up to 186f1a2 libssh2#132
Cherry-picked from libssh2#1727
In `_libssh2_mbedtls_pub_priv_key()` on a NON-error code path, a stack
variable was checked without initializing it first.
I found it interesting that clang-tidy did not find this when building
against the system mbedtls (2.x) with 2.x compatibility code still in.
Then it did find it when using a manual build of mbedtls 3.1.0 with
2.x compatibility code deleted from libssh2. Being such a trivial error
I wonder why no compiler ever detected it as a regular warning.
linux (clang-tidy, amd64, mbedTLS-prev [3.1.0], cmake, ON):
```
src/mbedtls.c:744:8: error: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch,-warnings-as-errors]
744 | if(ret) {
| ^
```
Ref: https://github.com/libssh2/libssh2/actions/runs/18620615649/job/53091295760#step:22:44
Follow-up to 186f1a2 #132
Cherry-picked from #1727
Closes #1729
"`mbed_pub_priv_key()` frees `pkey` on the unsupported-key path, but the caller (`ssh2_pub_privkey()`) unconditionally calls `mbedtls_pk_free(&pkey)` after this helper returns. That makes this a double-free on the error path (memory corruption). The helper should not free `pkey`; leave ownership/cleanup to the caller." Reported by Copilot Bug: #2501 (comment) Bug: #2501 (comment) Follow-up to 186f1a2 #132 Closes #2502
This rebases and squashes #106. I've also added support for mbedtls to the autotools build system and added some documentation on the new build system options.