From 1d6ed0a1b4e1a184ce6c8dd1fc4de9eb816013cd Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 16 Feb 2023 13:14:30 +0100 Subject: [PATCH] gpg: --gen-random code cleanup by using es_set_binary. * g10/gpg.c (main): Replace setmode by es_set_binary and use only when needed. -- It is better to use our es_set_binary than to use a Windows specific method which still worked but is fragile because estream might be changed. We now set binary only when needed. Note that it does not harm to call es_set_binary more often than needed. --- NEWS | 2 ++ g10/getkey.c | 2 +- g10/gpg.c | 4 +--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 3d28c9925..cd9c5ef59 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,8 @@ Noteworthy changes in version 2.2.42 (unreleased) * gpg: New list-options show-pref and show-pref-verbose. [rGb6ba7054a0] + * gpg: Add modes 16 and 30 to --gen-random. + * gpgsm: Support ECC certificates. [T6253] * gpgsm: Also announce AES256-CBC in signatures. [rGaa397fdcdb21] diff --git a/g10/getkey.c b/g10/getkey.c index 4642174e9..d883df63f 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -2763,7 +2763,7 @@ merge_selfsigs_main (ctrl_t ctrl, kbnode_t keyblock, int *r_revoked, * and there was no way to change it, so we start with the one * from the key packet. We do not support v3 keys anymore but * we keep the code in case a future key versions introduces a - * hadr expire time again. */ + * hard expire time again. */ key_expire = pk->max_expiredate; key_expire_seen = 1; } diff --git a/g10/gpg.c b/g10/gpg.c index 97ca93314..b22d79522 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -4945,9 +4945,6 @@ main (int argc, char **argv) size_t nn; p = gcry_random_bytes (n, level); -#ifdef HAVE_DOSISH_SYSTEM - setmode ( fileno(stdout), O_BINARY ); -#endif if (hexhack) { for (nn = 0; nn < n; nn++) @@ -4965,6 +4962,7 @@ main (int argc, char **argv) } else { + es_set_binary (es_stdout); es_fwrite( p, n, 1, es_stdout ); } xfree(p);