Repository navigation
Conversation
from gcc:
```
~/libssh2/src/agent.c:296:35: warning: 'snprintf' output truncated before the last format character [-Wformat-truncation=]
296 | "PageantRequest%08x%c", (unsigned)GetCurrentThreadId(), '\0');
| ^
```
Remove this tricky code, that aimed to ensure a terminating zero by
adding an extra one, for Microsoft platforms where we map `snprintf()`
to `_snprintf()`. The latter is famous for not guaranteeing
a terminating zero.
However, this was the single instance in libssh2 with this trick, even
though this particular case doesn't seem to be affected, as the output
shall fit into the buffer always, one terminating zero included.
Refs:
- https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l
"The _snprintf family of functions only appends a terminating null
character if the formatted string length is strictly less than count
characters."
- https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/2ts7cx93(v=vs.110)
vszakats
force-pushed
the
more-build-tidy-1
branch
from
March 3, 2023 21:48
1b0c51d to
42b05c7
Compare
The prerequisite for a successful detection is setting `LIBS=-lbcrypt` if the chosen openssl-compatible library requires it, e.g. libressl or quictls/openssl built with `-DUSE_BCRYPTGENRANDOM`. When using `llvm-ld`, detection works out of the box. When using binutils `ld`, it does not. The reason is `ld`s world-famous pickiness with lib order. To fix this case, we pass all custom libs before and after the tls libs. This ugly hack makes `ld` happy and detection succeeds.
vszakats
added a commit
to curl/curl-for-win
that referenced
this pull request
Mar 4, 2023
We usually suppress ./configure output for dependencies. Make an exception with libssh2, to have an obvious way to verify what it detects. E.g. I found out that gcc builds failed to detect `EVP_aes_128_ctr`. We switched to llvm/clang long ago, so this didn't affect curl-for-win binaries. Ref: libssh2/libssh2#811
and move `APPEND LIBRARIES ws2_32`s to top `CMakeLists.txt` Ref: libssh2#745 (comment)
vszakats
force-pushed
the
more-build-tidy-1
branch
from
March 6, 2023 15:08
f38512b to
972d622
Compare
llvm/clang:
```
./src/libssh2_priv.h:987:28: warning: variadic macros are a C99 feature [-Wvariadic-macros]
^
```
llvm/clang and gcc:
```
./src/libssh2_priv.h:990:8: warning: extension used [-Wlanguage-extension-token]
static inline void
^
```
Windows:
```
../../src/agent.c:318:10: warning: implicit conversion loses integer precision: 'LRESULT' (aka 'long long') to 'int' [-Wshorten-64-to-32]
id = SendMessage(hwnd, WM_COPYDATA, (WPARAM) NULL, (LPARAM) &cds);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Also favour __inline__ over __inline for __GNUC__. __inline__ is the documented syntax: https://gcc.gnu.org/onlinedocs/gcc/Inline.html
vszakats
force-pushed
the
more-build-tidy-1
branch
from
March 7, 2023 00:49
521b554 to
385bdae
Compare
example\direct_tcpip.c(209): warning C4244: 'function': conversion from 'unsigned int' to 'u_short', possible loss of data tests\session_fixture.c(96): warning C4013: 'getcwd' undefined; assuming extern returning int tests\session_fixture.c(100): warning C4013: 'chdir' undefined; assuming extern returning int
vszakats
force-pushed
the
more-build-tidy-1
branch
from
March 7, 2023 12:11
d1360ec to
33a1311
Compare
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Mar 19, 2023
libssh2 built with OpenSSL and without its HAVE_EVP_AES_128_CTR option are working incorrectly. This option wasn't always auto-detected by autotools up until recently (libssh2#811). non-cmake, non-autotools build methods never enabled it automatically. OpenSSL supports this options since at least v1.0.2, which is already EOLed and considered obsolete. OpenSSL forks (LibreSSL, BoringSSL) supported it all along. In this patch we enable this option unconditionally, now requiring OpenSSL v1.0.2 or newer or a fork. Also modernize OpenSSL lib references to what 1.0.2 and newer versions have been using. Fixes libssh2#739
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Mar 19, 2023
libssh2 built with OpenSSL and without its `HAVE_EVP_AES_128_CTR` option are working incorrectly. This option wasn't always auto-detected by autotools up until recently (libssh2#811). non-cmake, non-autotools build methods never enabled it automatically. OpenSSL supports this options since at least v1.0.2, which is already EOLed and considered obsolete. OpenSSL forks (LibreSSL, BoringSSL) supported it all along. In this patch we enable this option unconditionally, now requiring OpenSSL v1.0.2 or newer or a fork. Also modernize OpenSSL lib references to what 1.0.2 and newer versions have been using. Fixes libssh2#739
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Mar 19, 2023
libssh2 built with OpenSSL and without its `HAVE_EVP_AES_128_CTR` option are working incorrectly. This option wasn't always auto-detected by autotools up until recently (libssh2#811). Non-cmake, non-autotools build methods never enabled it automatically. OpenSSL supports this options since at least v1.0.2, which is already EOLed and considered obsolete. OpenSSL forks (LibreSSL, BoringSSL) supported it all along. In this patch we enable this option unconditionally, now requiring OpenSSL v1.0.2 or newer or a fork. Also modernize OpenSSL lib references to what 1.0.2 and newer versions have been using. Fixes libssh2#739
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Mar 19, 2023
libssh2 built with OpenSSL and without its `EVP_aes_128_ctr()`, aka `HAVE_EVP_AES_128_CTR` option are working incorrectly. This option wasn't always auto-detected by autotools up until recently (libssh2#811). Non-cmake, non-autotools build methods never enabled it automatically. OpenSSL supports this options since at least v1.0.2, which is already EOLed and considered obsolete. OpenSSL forks (LibreSSL, BoringSSL) supported it all along. In this patch we enable this option unconditionally, now requiring OpenSSL supporting this function, or one of its forks. Also modernize OpenSSL lib references to what 1.0.2 and newer versions have been using. Fixes libssh2#739
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Mar 19, 2023
libssh2 built with OpenSSL and without its `EVP_aes_128_ctr()`, aka `HAVE_EVP_AES_128_CTR`, option are working incorrectly. This option wasn't always auto-detected by autotools up until recently (libssh2#811). Non-cmake, non-autotools build methods never enabled it automatically. OpenSSL supports this options since at least v1.0.2, which is already EOLed and considered obsolete. OpenSSL forks (LibreSSL, BoringSSL) supported it all along. In this patch we enable this option unconditionally, now requiring OpenSSL supporting this function, or one of its forks. Also modernize OpenSSL lib references to what 1.0.2 and newer versions have been using. Fixes libssh2#739
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Mar 19, 2023
libssh2 built with OpenSSL and without its `EVP_aes_128_ctr()`, aka `HAVE_EVP_AES_128_CTR`, option are working incorrectly. This option wasn't always auto-detected by autotools up until recently (libssh2#811). Non-cmake, non-autotools build methods never enabled it automatically. No build method auto-detected or enabled it for wolfSSL either. OpenSSL supports this options since at least v1.0.2, which is already EOLed and considered obsolete. OpenSSL forks (LibreSSL, BoringSSL) supported it all along. In this patch we enable this option unconditionally, now requiring OpenSSL supporting this function, or one of its forks, or wolfSSL. Also modernize OpenSSL lib references to what 1.0.2 and newer versions have been using. Fixes libssh2#739
vszakats
added a commit
that referenced
this pull request
Mar 20, 2023
libssh2 built with OpenSSL and without its `EVP_aes_128_ctr()`, aka `HAVE_EVP_AES_128_CTR`, option are working incorrectly. This option wasn't always auto-detected by autotools up until recently (#811). Non-cmake, non-autotools build methods never enabled it automatically. OpenSSL supports this options since at least v1.0.2, which is already EOLed and considered obsolete. OpenSSL forks (LibreSSL, BoringSSL) supported it all along. In this patch we enable this option unconditionally, now requiring OpenSSL supporting this function, or one of its forks. Also modernize OpenSSL lib references to what 1.0.2 and newer versions have been using. Fixes #739
agreppin
pushed a commit
to agreppin/libssh2
that referenced
this pull request
Jul 14, 2024
- cmake: always link `ws2_32` on Windows. Also add it to `libssh2.pc`. Fixes libssh2#745 - agent: fix gcc compiler warning: `src/agent.c:296:35: warning: 'snprintf' output truncated before the last format character [-Wformat-truncation=]` - autotools: fix `EVP_aes_128_ctr` detection with binutils `ld` The prerequisite for a successful detection is setting `LIBS=-lbcrypt` if the chosen openssl-compatible library requires it, e.g. libressl, or quictls/openssl built with `-DUSE_BCRYPTGENRANDOM`. With llvm `lld`, detection works out of the box. With binutils `ld`, it does not. The reason is `ld`s world-famous pickiness with lib order. To fix it, we pass all custom libs before and after the TLS libs. This ugly hack makes `ld` happy and detection succeed. - agent: fix Windows-specific warning: `src/agent.c:318:10: warning: implicit conversion loses integer precision: 'LRESULT' (aka 'long long') to 'int' [-Wshorten-64-to-32]` - src: fix llvm/clang compiler warning: `src/libssh2_priv.h:987:28: warning: variadic macros are a C99 feature [-Wvariadic-macros]` - src: support `inline` with `__GNUC__` (llvm/clang and gcc), fixing: ``` src/libssh2_priv.h:990:8: warning: extension used [-Wlanguage-extension-token] static inline void ^ ``` - blowfish: support `inline` keyword with MSVC. Also switch to `__inline__` (from `__inline`) for `__GNUC__`: https://gcc.gnu.org/onlinedocs/gcc/Inline.html https://clang.llvm.org/docs/UsersManual.html#differences-between-various-standard-modes - example/test: fix MSVC compiler warnings: - `example\direct_tcpip.c(209): warning C4244: 'function': conversion from 'unsigned int' to 'u_short', possible loss of data` - `tests\session_fixture.c(96): warning C4013: 'getcwd' undefined; assuming extern returning int` - `tests\session_fixture.c(100): warning C4013: 'chdir' undefined; assuming extern returning int` - delete unused macros: - `HAVE_SOCKET` - `HAVE_INET_ADDR` - `NEED_LIB_NSL` - `NEED_LIB_SOCKET` - `HAVE_NTSTATUS_H` - `HAVE_NTDEF_H` - build: delete stale zlib/openssl version numbers from path defaults. - cmake: convert tabs to spaces, add newline at EOFs. Closes libssh2#811
agreppin
pushed a commit
to agreppin/libssh2
that referenced
this pull request
Jul 14, 2024
libssh2 built with OpenSSL and without its `EVP_aes_128_ctr()`, aka `HAVE_EVP_AES_128_CTR`, option are working incorrectly. This option wasn't always auto-detected by autotools up until recently (libssh2#811). Non-cmake, non-autotools build methods never enabled it automatically. OpenSSL supports this options since at least v1.0.2, which is already EOLed and considered obsolete. OpenSSL forks (LibreSSL, BoringSSL) supported it all along. In this patch we enable this option unconditionally, now requiring OpenSSL supporting this function, or one of its forks. Also modernize OpenSSL lib references to what 1.0.2 and newer versions have been using. Fixes libssh2#739
vszakats
added a commit
to vszakats/libssh2
that referenced
this pull request
Jul 13, 2025
The `libssh2.pc` generator logic automatically adds `-lws2_32` while parsing `LIBSSH2_LIBS`, which contains this lib already. Then discard the duplicate. This change introduces a change in the position of `ws2_32` within the lib list. This order might in cases by significant, but: - libssh2 no longer links against `libssl`, which was the library also referencing `ws2_32` and breaking picky binutils `ld` linker when not passed in strict dependency order. Ref: c84745e libssh2#1128 - since switching to INTERFACE targets, cmake messes up the lib order anyway, adding `OpenSSL:Crypto` last, instead of `ws2_32`. This did not seem to cause an issue so far. Ref: df0563a libssh2#1535 Ref: 33b6d5f libssh2#827 Ref: 31fb886 libssh2#811
vszakats
added a commit
that referenced
this pull request
Jul 13, 2025
The `libssh2.pc` generator logic automatically adds `-lws2_32` while parsing `LIBSSH2_LIBS`, which contains this lib already. Then discard the duplicate. This patch introduces a change in the position of `ws2_32` within the lib list advertised via `libssh2.pc` for static builds. This order might in cases by significant, but: - libssh2 no longer links against `libssl`, which was the library also referencing `ws2_32` and breaking picky binutils `ld` linker when not passed in strict dependency order. Ref: c84745e #1128 - since switching to INTERFACE targets, cmake messes up the lib order anyway, adding `OpenSSL:Crypto` last, instead of `ws2_32`. This did not seem to cause an issue so far. Ref: df0563a #1535 For these reasons it seems unlikely this position change could break Windows OpenSSL static gcc/ld builds relying on `libssh2.pc` for their lib list. It least no more than it was before this patch. Turns out these theories don't stand in practice and the order is broken possibly by introducing INTERFACE targets, with or without this patch. `libcrypto` (tested with LibreSSL) is in fact depending on `ws2_32`, and the `bcrypt` dependency is also causing breakage with picky binutils ld. I may try addressing it in a separate PR. Ref: 33b6d5f #827 Ref: 31fb886 #811 Closes #1619
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.
cmake: always link
ws2_32on Windows. Also add it tolibssh2.pc.Fixes Add missing winsock2 link library #745
agent: fix gcc compiler warning:
src/agent.c:296:35: warning: 'snprintf' output truncated before the last format character [-Wformat-truncation=]autotools: fix
EVP_aes_128_ctrdetection with binutilsldThe prerequisite for a successful detection is setting
LIBS=-lbcryptif the chosen openssl-compatible library requires it, e.g. libressl,
or quictls/openssl built with
-DUSE_BCRYPTGENRANDOM.With llvm
lld, detection works out of the box. With binutilsld,it does not. The reason is
lds world-famous pickiness with lib order.To fix it, we pass all custom libs before and after the TLS libs.
This ugly hack makes
ldhappy and detection succeed.agent: fix Windows-specific warning:
src/agent.c:318:10: warning: implicit conversion loses integer precision: 'LRESULT' (aka 'long long') to 'int' [-Wshorten-64-to-32]llvm/clang: fix warning:
src/libssh2_priv.h:987:28: warning: variadic macros are a C99 feature [-Wvariadic-macros]support
inlinewith__GNUC__(llvm/clang and gcc), fixing:blowfish: support
inlinekeyword with MSVC.Also switch to
__inline__(from__inline) for__GNUC__:https://gcc.gnu.org/onlinedocs/gcc/Inline.html
https://clang.llvm.org/docs/UsersManual.html#differences-between-various-standard-modes
fix MSVC compiler warnings:
example\direct_tcpip.c(209): warning C4244: 'function': conversion from 'unsigned int' to 'u_short', possible loss of datatests\session_fixture.c(96): warning C4013: 'getcwd' undefined; assuming extern returning inttests\session_fixture.c(100): warning C4013: 'chdir' undefined; assuming extern returning intdelete unused macros:
HAVE_SOCKETHAVE_INET_ADDRNEED_LIB_NSLNEED_LIB_SOCKETHAVE_NTSTATUS_HHAVE_NTDEF_Hdelete stale zlib/openssl version numbers from path defaults.
cmake: convert tabs to spaces, add newline at EOFs.
Closes #811