=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/openssl/gendh.c,v retrieving revision 1.11 retrieving revision 1.12 diff -c -r1.11 -r1.12 *** src/usr.bin/openssl/gendh.c 2019/07/14 03:30:45 1.11 --- src/usr.bin/openssl/gendh.c 2021/11/20 18:10:48 1.12 *************** *** 1,4 **** ! /* $OpenBSD: gendh.c,v 1.11 2019/07/14 03:30:45 guenther Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * --- 1,4 ---- ! /* $OpenBSD: gendh.c,v 1.12 2021/11/20 18:10:48 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * *************** *** 84,90 **** #define DEFBITS 512 ! static int dh_cb(int p, int n, BN_GENCB * cb); static struct { int g; --- 84,90 ---- #define DEFBITS 512 ! static int dh_cb(int p, int n, BN_GENCB *cb); static struct { int g; *************** *** 128,134 **** int gendh_main(int argc, char **argv) { ! BN_GENCB cb; DH *dh = NULL; int ret = 1, numbits = DEFBITS; BIO *out = NULL; --- 128,134 ---- int gendh_main(int argc, char **argv) { ! BN_GENCB *cb = NULL; DH *dh = NULL; int ret = 1, numbits = DEFBITS; BIO *out = NULL; *************** *** 141,148 **** } } ! BN_GENCB_set(&cb, dh_cb, bio_err); memset(&gendh_config, 0, sizeof(gendh_config)); gendh_config.g = 2; --- 141,153 ---- } } ! if ((cb = BN_GENCB_new()) == NULL) { ! BIO_printf(bio_err, "Error allocating BN_GENCB object\n"); ! goto end; ! } + BN_GENCB_set(cb, dh_cb, bio_err); + memset(&gendh_config, 0, sizeof(gendh_config)); gendh_config.g = 2; *************** *** 180,186 **** BIO_printf(bio_err, "This is going to take a long time\n"); if (((dh = DH_new()) == NULL) || ! !DH_generate_parameters_ex(dh, numbits, gendh_config.g, &cb)) goto end; if (!PEM_write_bio_DHparams(out, dh)) --- 185,191 ---- BIO_printf(bio_err, "This is going to take a long time\n"); if (((dh = DH_new()) == NULL) || ! !DH_generate_parameters_ex(dh, numbits, gendh_config.g, cb)) goto end; if (!PEM_write_bio_DHparams(out, dh)) *************** *** 190,202 **** if (ret != 0) ERR_print_errors(bio_err); BIO_free_all(out); DH_free(dh); return (ret); } static int ! dh_cb(int p, int n, BN_GENCB * cb) { char c = '*'; --- 195,208 ---- if (ret != 0) ERR_print_errors(bio_err); BIO_free_all(out); + BN_GENCB_free(cb); DH_free(dh); return (ret); } static int ! dh_cb(int p, int n, BN_GENCB *cb) { char c = '*'; *************** *** 208,215 **** c = '*'; if (p == 3) c = '\n'; ! BIO_write(cb->arg, &c, 1); ! (void) BIO_flush(cb->arg); return 1; } #endif --- 214,221 ---- c = '*'; if (p == 3) c = '\n'; ! BIO_write(BN_GENCB_get_arg(cb), &c, 1); ! (void) BIO_flush(BN_GENCB_get_arg(cb)); return 1; } #endif