On Sun, Feb 26, 2017 at 11:49:13AM +0100, Daniel Cegiełka wrote: > 2017-02-26 8:27 GMT+01:00 Otto Moerbeek <o...@drijf.net>: > > On Sat, Feb 25, 2017 at 11:28:43PM +0100, Daniel Cegiełka wrote: > > > > > > > Bleh, they could have changed the implementation without changing the > > API but they choose not to and place the burden on the user of the lib. > > > > Easy "fix" would be to remove the BN_check, but in current compat mode > > that would lead to a unchecked mem allocation. Don't like that at all. > > > > https://github.com/openbsd/src/blob/master/lib/libcrypto/bn/bn_lib.c#L564 > > BN_set_word() is not mark as DEPRECATED and bn_check() call it many times: > > $ grep BN_set_word bcode.c|grep bn_check > bn_check(BN_set_word(a, 10)); > bn_check(BN_set_word(p, abs_scale)); > bn_check(BN_set_word(f, rem)); > bn_check(BN_set_word(a, 10)); > bn_check(BN_set_word(p, n->scale)); > bn_check(BN_set_word(n->number, bmachine.scale)); > bn_check(BN_set_word(n->number, bmachine.obase)); > bn_check(BN_set_word(n->number, bmachine.ibase)); > bn_check(BN_set_word(n->number, i)); > bn_check(BN_set_word(n->number, scale)); > bn_check(BN_set_word(n->number, digits)); > bn_check(BN_set_word(n->number, digits)); > bn_check(BN_set_word(a->number, BN_get_word(a->number) ? 0 : 1)); > bn_check(BN_set_word(r->number, > bn_check(BN_set_word(r->number, > bn_check(BN_set_word(r->number, > > so instead BN_zero we can use BN_set_word() directly: > > bn_check(BN_set_word(BIGNUM_VAR, 0)); > > Daniel
Indeed, commited, Thanks, -Otto > > > > -Otto > diff -urN dc.orig/bcode.c dc.new/bcode.c > --- dc.orig/bcode.c Sat Feb 25 10:58:20 2017 > +++ dc.new/bcode.c Sun Feb 26 10:40:55 2017 > @@ -386,7 +386,7 @@ > bn_checkp(BN_copy(i, n->number)); > > if (n->scale == 0 && f != NULL) > - bn_check(BN_zero(f)); > + bn_check(BN_set_word(f, 0)); > else if (n->scale < sizeof(factors)/sizeof(factors[0])) { > rem = BN_div_word(i, factors[n->scale]); > if (f != NULL) > @@ -804,7 +804,7 @@ > v = stack_tos(&bmachine.reg[idx]); > if (v == NULL) { > n = new_number(); > - bn_check(BN_zero(n->number)); > + bn_check(BN_set_word(n->number, 0)); > push_number(n); > } else > push(stack_dup_value(v, ©)); > @@ -888,7 +888,7 @@ > v = frame_retrieve(stack, idx); > if (v == NULL || v->type == BCODE_NONE) { > n = new_number(); > - bn_check(BN_zero(n->number)); > + bn_check(BN_set_word(n->number, 0)); > push_number(n); > } > else > diff -urN dc.orig/inout.c dc.new/inout.c > --- dc.orig/inout.c Thu Feb 2 22:16:20 2017 > +++ dc.new/inout.c Sun Feb 26 10:41:17 2017 > @@ -186,7 +186,7 @@ > u_int i; > > n = new_number(); > - bn_check(BN_zero(n->number)); > + bn_check(BN_set_word(n->number, 0)); > > while ((ch = (*src->vtable->readchar)(src)) != EOF) { >