aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2024-02-21 14:55:14 +0000
committerWerner Koch <[email protected]>2024-02-21 14:55:14 +0000
commit2372f6a4035cefd5ac1852e95dc50de89cc73af6 (patch)
tree594a72eb084e128286d258dc0fd978e255be49d4
parentwks: Allow command style args for gpg-wks-client. (diff)
downloadgnupg-2372f6a4035cefd5ac1852e95dc50de89cc73af6.tar.gz
gnupg-2372f6a4035cefd5ac1852e95dc50de89cc73af6.zip
gpg: Fix gpg_mpi_write for the unused opaque case.
* g10/build-packet.c (gpg_mpi_write): Take care of the fact that get_opaque already returns a bit-exact value. -- Fixes-commit: ab17f7b6c392782718f57eaea94fc18a0ff49389 Reported-by: Falko Strenzke <[email protected]>
-rw-r--r--g10/build-packet.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/g10/build-packet.c b/g10/build-packet.c
index 67d4a6eef..19a13760a 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -306,7 +306,9 @@ gpg_mpi_write (iobuf_t out, gcry_mpi_t a, unsigned int *r_nwritten)
p = gcry_mpi_get_opaque (a, &nbits);
if (p)
{
- /* Strip leading zero bits. */
+ /* First get nbits back to full bytes. */
+ nbits = ((nbits + 7) / 8) * 8;
+ /* Then strip leading zero bits. */
for (; nbits >= 8 && !*p; p++, nbits -= 8)
;
if (nbits >= 8 && !(*p & 0x80))