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

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 95c824d5d9 #1354
Follow-up to c9d40afa14

Closes #2596
This commit is contained in:
Viktor Szakats
2026-09-07 16:04:47 +02:00
parent 13e1042b99
commit f0ac38ab93

View File

@@ -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) \