1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-10-24 03:48:58 +03:00
Commit Graph

32 Commits

Author SHA1 Message Date
Viktor Szakats
3f718eaa90 tidy-up: comment and formatting fixes
Closes #2525
2026-08-14 01:58:59 +02:00
Viktor Szakats
3e14d67d26 mac: disable SHA1-based MACs by default
Also:
- RELEASE-NOTES: announce removal after next release.
- allow build-time macro to enable in the meantime.
- skip in tests if disabled.
- keep testing in CI with other legacy options.
- workaround oss-fuzzer hang and timeout after 10 minutes by keeping
  SHA1-based MACs enabled in the fuzzer build.
  Ref: https://github.com/libssh2/libssh2/pull/2444#issuecomment-5110853610

Follow-up to 99f935358d #2443

Closes #2444
2026-07-29 02:53:01 +02:00
Viktor Szakats
6857c88cda ossfuzz.sh: disable build options unnecessary for fuzzing
To shorten log output and maybe save a couple of seconds.

Closes #2447
2026-07-29 02:27:14 +02:00
Viktor Szakats
76d30e5d98 build: set LIBSSH2_TESTS macro for all tests
To apply to all test apps. Prior to this patch it was set for fixtures only.

Ref: https://github.com/libssh2/libssh2/pull/2408#issuecomment-5061010305

Closes #2417
2026-07-23 23:07:30 +02:00
Viktor Szakats
521146a4f1 src: add Unicode, long-filename, and secure fopen() support (Windows)
Low-level logic copied from curl, and adapted to libssh2.

Also: use secure fopen CRT functions.

Credits-to: Jay Satiro
Credits-to: Viktor Szakats

Closes #2318
2026-07-15 15:31:58 +02:00
Viktor Szakats
f2ec1f2f34 scripts: minor fixes and improvements
- pass `--` before passing input files.
- scripts/maketgz: robustify `rm` invocations.
- prefer `$(pwd)` or `$PWD`.
- tests/cmake/test.sh: dump configs to CI log.
- tests/gen_keys.sh: fix to skip DSA if missing.
- replace openssl with `base` and `*sum` tools.
- tests/ossfuzz/ossfuzz.sh: fix to add a space before `-j`.

Closes #2265
2026-07-09 14:47:52 +02:00
Viktor Szakats
33f6508a58 tidy-up: drop most {} blocks around single-statements
Follow-up to b171deefde #2077
Follow-up to 28824712fe #2004

Closes #2087
2026-06-21 04:59:48 +02:00
Viktor Szakats
10093bde93 tidy-up: miscellaneous
- tests: replace include `<libssh2.h>` with `"libssh2.h"`.
- tests/test_hostkey_hash: replace stray `%i` printf masks with `%d`.
- misc: drop redundant NULL assignment in `ssh2_string_buf_free()`.
- misc: add casts for consistency in `ssh2_ntohu64()`.
- ssh2_client_fuzzer.cc: drop redundant/unused includes.
- fix typos in comment.
- unfold lines.

Closes #2000
2026-06-08 18:42:49 +02:00
Viktor Szakats
509eac8b96 checksrc: extend to ossfuzz, reduce scope of exceptions
Replace a few calls in tests to reduce exceptions.

Closes #1998
2026-06-08 17:14:59 +02:00
Viktor Szakats
9538c99fc4 badwords: add checker script, fix issues found
Checker script and wordlist comes from curl.

Also:
- checksrc.pl: sync up with curl.
- unfold an IETF URL.
- update all IETF URLs where missing.

Closes #1959
2026-06-01 13:22:40 +02:00
Viktor Szakats
63e59481fa src: formatting (cont.)
- apply manually selected clang-format fixes.
- apply manual formatting fixes.
- move return type inline with the declaration.
  (for private APIs)
- os400qc3: fix missed `_libssh2_dh_ctx` -> `libssh2_dh_ctx`.
  Follow-up to 689b202320 #1923
- os400qc3: drop redundant line-continuation backslashes.
- delete copy of function name from function top comments.
- move literal to right hand side in a couple of comparisons.
- drop redundant `extern` keywords.

Follow-up to 6ffb96321c #1935

Closes #1936
2026-05-13 12:00:36 +02:00
Viktor Szakats
ac7b9b214a cmake: drop support for CMake 3.17 and older
Require CMake 3.18 (2020-07-15) or newer, up from 3.7 (2016-11-11) prior
to this patch.

This requirement also applies to the distributed `libssh2-config.cmake`.

To allow dropping compatibility code maintained for old versions, and to
use features which were unpractical in separate code paths. Also to make
testing, documentation and development easier, and builds faster due
CMake performance improvements over time.

CMake offers pre-built binaries for major platforms. They work without
an install step, just by unpacking and pointing the cmake command to
them. Making upgrades easy in many cases:
https://cmake.org/download/
https://cmake.org/files/
https://github.com/Kitware/CMake/releases

CMake 3.18 brings these feature as generally available when building or
consuming curl/libcurl:

LTO support, improved performance, `pkg-config` and interface target
support, `OBJECT` target (for faster libcurl builds), modern invocation
with `-S`/`-B` options, better support for custom linker options,
FetchContent, `--verbose` and `--install` options, `CMAKE_GENERATOR`
env, last but not least unity mode and Ninja generator.

Ref: https://github.com/curl/curl/discussions/18704

Closes #1839
2026-04-10 21:59:24 +02:00
Ze Sheng
e7e0383b23 fuzz: replace assert() with goto in ssh2_client_fuzzer (#1823)
## Summary

Replace `assert()` with `goto EXIT_LABEL` in the `FUZZ_ASSERT` macro in
`ssh2_client_fuzzer.cc`.

### Problem

When `socketpair()` fails (e.g., due to file descriptor exhaustion
during long fuzzing runs), `FUZZ_ASSERT(rc == 0)` calls `assert()`,
which aborts the entire fuzzer process. LibFuzzer expects harnesses to
handle errors gracefully by returning 0 — aborting terminates the
fuzzing campaign.

The rest of the fuzzer already uses `goto EXIT_LABEL` for error handling
(lines 38, 53, 59, 69, 73), so the `assert()` in `FUZZ_ASSERT` is
inconsistent with the existing pattern.

### Fix

Change `assert((COND))` to `goto EXIT_LABEL` in the `FUZZ_ASSERT` macro,
making it consistent with all other error paths in the fuzzer.

## Coverage comparison (60 seconds, empty seed corpus, ASan, libFuzzer)

| Metric | Original | Fixed | Change |
|--------|----------|-------|--------|
| Edge coverage | 320 | 373 | +16.56% (+53 edges) |
| Feature coverage | 696 | 778 | +11.78% (+82 features) |

Note: The coverage improvement may be due to fuzzer randomness rather
than the fix itself, but it confirms the fix does not regress coverage.

Credit:
Ze Sheng
2026-03-30 16:53:43 -07:00
Viktor Szakats
4f9e6e0bfb REUSE: add copyright headers to more files, and .gitignore updates
Also:
- rename a spellcheck file to match curl.
- editorconfig: fix line width.
- editorconfig: make it use UTF-8.
- editroconfig: apply some rules to all files.
- .gitignore: drop dupe, drop `.DS_Store` (not created by this repo),
   sort.
- .gitignore: add for tests executables.

Closes #1718
2025-10-13 13:35:25 +02:00
Viktor Szakats
61d51cb449 cmake: tidy up passing compiler and linker options
- prefer `set_property()` over `target_compile_options()`, to use
  the modern style.

  Follow-up to 8017592163 #939

- prefer to append to compiler/linker options in examples/tests.
  To prevent accidentally overriding a previously set option.

  Follow-up to 14a709a72f #1686
  Follow-up to 854cfa8292 #1524

- replace `LINK_FLAGS` with `LINK_OPTIONS` that superceded it, for
  CMake 3.13+.

  Follow-up to 854cfa8292 #1524
  https://cmake.org/cmake/help/v4.1/prop_tgt/LINK_OPTIONS.html

Closes #1690
2025-09-29 13:32:46 +02:00
Viktor Szakats
90a686ef3a gitignore: compress rules
Cherry-picked from #1484
2025-01-31 02:00:28 +01:00
Viktor Szakats
96cbe61896 ossfuzz: fix picky compiler warnings, make it pass checksrc
- fix compiler warnings.
- make it pass `checksrc`.
- fix shell `set -u` errors.
  Follow-up to 5012442850 #901
- REUSE: tidy up ossfuzz files.

Cherry-picked from #1484
Closes #1526
2025-01-30 23:36:39 +01:00
Viktor Szakats
854cfa8292 build: prepare builds for clang-cl, add cmake ossfuzz support
- cmake: add support to build ossfuzz.
  Enable with `-DBUILD_OSSFUZZ=ON`.
  Also supports `-DLIB_FUZZING_ENGINE=` like autotools does.
- check for `__clang__` when suppressing warnings in source. Necessary
  for clang-cl, which set `__clang__`, but doesn't set `__GNU__`.
- cmake: optimize out 4 picky warning option detections with gcc.
- cmake: bring `-pedantic-error`, `-Wall` use closer to curl's.
- cmake: set `-Wno-language-extension-token` for clang-cl.
- cmake: escape only the necessary `-W` options for clang-cl.
- cmake: apply picky warnings to C++.
- cmake: replace `unset(VAR)` with `set(VAR "")` for init.
- cmake: prefer dash-style MSVC options.
- cmake: simplify `MATCHES` expression.
- cmake: formatting/whitespace.
- ci/GHA: bump `actions/upload-artifact` to v4

Closes #1524
2025-01-30 22:01:49 +01:00
Viktor Szakats
1117b677a0 checksrc: update, check all sources, fix fallouts
update from curl:
cff75acfec/scripts/checksrc.pl

Closes #1457
2024-09-28 11:41:52 +02:00
Viktor Szakats
814a850c97 buildconf: drop
Use `autoreconf -fi` instead.

Follow-up to fc5d77881e
Closes #1441
2024-08-07 18:19:15 +02:00
Viktor Szakats
bfa00f1bd5 tidy-up: around stdint.h
- os400: delete unused `HAVE_STDINT_H`.

- fuzz: delete redundant `stdint.h` use.
  `inttypes.h` is already included via `testinput.h`.

- docs/TODO: adjust type in planned function.

Closes #1212
2023-11-06 15:00:08 +00:00
Viktor Szakats
003fb454c3 tidy-up: avoid exclamations, prefer single quotes, in outputs
Closes #1079
2023-06-03 12:51:56 +00:00
Viktor Szakats
2efdb6747a tidy-up: example, tests continued
- fix skip auth if `userauthlist` is NULL.
  Closes #836 (Reported-by: @sudipm-mukherjee on github)
- fix most silenced `checksrc` warnings.
- sync examples/tests code between each other.
  (output messages, error handling, declaration order, comments)
- stop including unnecessary headers.
- always deinitialize in case of error.
- drop some redundant variables.
- add error handling where missing.
- show more error codes.
- switch `perror()` to `fprintf()`.
- fix some `printf()`s to be `fprintf()`.
- formatting.

Closes #960
2023-04-14 11:07:53 +00:00
Viktor Szakats
5012442850 maketgz: tidy-up [ci skip] (#901)
- fix shellcheck warnings:
  - use quotes
  - use `$()`
- use `printf` (instead of calling perl).
- indent.
- copy/adapt header comment from curl to `maketgz`.
2023-03-30 20:59:47 +02:00
Viktor Szakats
2f16d8105c tidy-up: replace tabs and other whitespace (#885)
There are a few non-whitespace changes, see them here:
https://github.com/libssh2/libssh2/pull/885/files?w=1
2023-03-27 18:28:27 +02:00
Dan Fandrich
16619a8edd Add missing files to automake makefiles & build tests
Many files have been added to the cmake build files but not the automake
ones in recent years. Missing ones have been added so automake "make
dist" will now create a usable tar ball.

The integration tests using Docker are now built with automake as well
(with "make check").  They are not run yet since they aren't working yet
on Linux.
2023-01-06 10:47:32 -08:00
Will Cosgrove
dd0b5b2d2b Changed NULL check to avoid logic change 2022-04-11 09:49:00 -07:00
Will Cosgrove
3489ee9a6f NULL check before calling session_handshake 2022-04-11 09:46:52 -07:00
Gabriel Smith
ee199144fe ci: Swap from Travis to Github Actions (#581)
Files: ci files

Notes:
Move Linux CI using Github Actions

Credit:
Gabriel Smith, Marc Hörsken
2021-04-30 16:10:52 -07:00
Will Cosgrove
8ae21cad83 ssh2_client_fuzzer.cc: fixed building
The GitHub web editor did some funky things
2021-02-05 10:05:52 -08:00
Will Cosgrove
384a50e0e4 ssh_client_fuzzer.cc: set blocking mode on (#553)
file: ssh_client_fuzzer.cc

notes: the session needs blocking mode turned on to avoid EAGAIN being returned from libssh2_session_handshake()

credit:
Will Cosgrove, reviewed by Michael Buckley
2021-02-04 09:56:16 -08:00
Max Dymond
7a4b051ba4 Add support for an OSS Fuzzer fuzzing target (#392)
Files:
.travis.yml, configure.ac, ossfuzz 

Notes:
This adds support for an OSS-Fuzz fuzzing target in ssh2_client_fuzzer,
which is a cut down example of ssh2.c. Future enhancements can improve
coverage.

Credit:
Max Dymond
2020-09-01 14:20:52 -07:00