From f0ac38ab93b0050bd72bc8405f613dfc49a7b658 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 7 Sep 2026 16:04:47 +0200 Subject: [PATCH] libgcrypt: fix `ssh2_bn_set_word()` return value It was returning a non-NULL address on success, which translated to permanent failure as mapped to this internal crypto API. Fix to match it with the rest of crypto backends and the expectation of callers. Reported by Copilot Bug: https://github.com/libssh2/libssh2/pull/2595#discussion_r3950301182 Follow-up to 95c824d5d9555827d5e3616d1404502c052682fb #1354 Follow-up to c9d40afa14cd9400124467ced69fee387f9c50fa Closes #2596 --- src/libgcrypt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libgcrypt.h b/src/libgcrypt.h index 1f773225..e302bf63 100644 --- a/src/libgcrypt.h +++ b/src/libgcrypt.h @@ -116,7 +116,7 @@ #define ssh2_bn struct gcry_mpi #define ssh2_bn_init() gcry_mpi_new(0) -#define ssh2_bn_set_word(bn, word) gcry_mpi_set_ui(bn, word) +#define ssh2_bn_set_word(bn, word) (gcry_mpi_set_ui(bn, word) ? 0 : 1) #define ssh2_bn_from_bin(bn, bin, len) \ gcry_mpi_scan(bn, GCRYMPI_FMT_USG, bin, len, NULL) #define ssh2_bn_to_bin(bn, bin) \