~ubuntu-branches/ubuntu/utopic/dropbear/utopic-proposed

« back to all changes in this revision

Viewing changes to libtommath/bn_mp_rand.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Johnston
  • Date: 2005-12-08 19:20:21 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051208192021-nyp9rwnt77nsg6ty
Tags: 0.47-1
* New upstream release.
* SECURITY: Fix incorrect buffer sizing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
  /* first place a random non-zero digit */
31
31
  do {
32
 
    d = ((mp_digit) abs (rand ()));
 
32
    d = ((mp_digit) abs (rand ())) & MP_MASK;
33
33
  } while (d == 0);
34
34
 
35
35
  if ((res = mp_add_d (a, d, a)) != MP_OKAY) {
36
36
    return res;
37
37
  }
38
38
 
39
 
  while (digits-- > 0) {
 
39
  while (--digits > 0) {
40
40
    if ((res = mp_lshd (a, 1)) != MP_OKAY) {
41
41
      return res;
42
42
    }