Bug#654442: pu: package erlang/14.a-dfsg-3squeeze1
On Tue, Jan 3, 2012 at 22:49:33 +0400, Sergei Golovan wrote:
[...]
> ++static ERL_NIF_TERM strong_rand_mpint_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
> ++{/* (Bytes, TopMask, BottomMask) */
> ++ unsigned bits;
> ++ BIGNUM *bn_rand;
> ++ int top, bottom;
> ++ unsigned char* data;
> ++ unsigned dlen;
> ++ ERL_NIF_TERM ret;
> ++ if (!enif_get_uint(env, argv[0], &bits)
> ++ || !enif_get_int(env, argv[1], &top)
> ++ || !enif_get_int(env, argv[2], &bottom)) {
> ++ return enif_make_badarg(env);
> ++ }
> ++ if (! (top == -1 || top == 0 || top == 1) ) {
> ++ return enif_make_badarg(env);
> ++ }
> ++ if (! (bottom == 0 || bottom == 1) ) {
> ++ return enif_make_badarg(env);
> ++ }
> ++
> ++ bn_rand = BN_new();
> ++ if (! bn_rand ) {
> ++ return enif_make_badarg(env);
badarg seems a bit weird here, it's got nothing to do with its args?
> ++ }
> ++
> ++ /* Get a (bits) bit random number */
> ++ if (!BN_rand(bn_rand, bits, top, bottom)) {
> ++ ret = atom_false;
> ++ }
> ++ else {
> ++ /* Copy the bignum into an erlang mpint binary. */
> ++ dlen = BN_num_bytes(bn_rand);
> ++ data = enif_make_new_binary(env, dlen+4, &ret);
> ++ put_int32(data, dlen);
> ++ BN_bn2bin(bn_rand, data+4);
> ++ ERL_VALGRIND_MAKE_MEM_DEFINED(data+4, dlen);
> ++ }
> ++ BN_free(bn_rand);
> ++
> ++ return ret;
> ++}
> +
> + static int get_bn_from_mpint(ErlNifEnv* env, ERL_NIF_TERM term, BIGNUM** bnp)
> + {
[...]
> +--- erlang-14.a-dfsg.orig/lib/ssh/src/ssh_bits.erl
> ++++ erlang-14.a-dfsg/lib/ssh/src/ssh_bits.erl
> +@@ -34,7 +34,7 @@
> + %% integer utils
> + -export([isize/1]).
> + -export([irandom/1, irandom/3]).
> +--export([random/1, random/3]).
> ++-export([random/1]).
> + -export([xor_bits/2, fill_bits/2]).
> + -export([i2bin/2, bin2i/1]).
> +
Am I reading this right that random/3 gets unexported? Is this safe
(i.e. are you sure this was always unused)?
Cheers,
Julien
Reply to: