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

« back to all changes in this revision

Viewing changes to libtommath/bn_mp_lcm.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:
28
28
 
29
29
  /* t1 = get the GCD of the two inputs */
30
30
  if ((res = mp_gcd (a, b, &t1)) != MP_OKAY) {
31
 
    goto __T;
 
31
    goto LBL_T;
32
32
  }
33
33
 
34
34
  /* divide the smallest by the GCD */
35
35
  if (mp_cmp_mag(a, b) == MP_LT) {
36
36
     /* store quotient in t2 such that t2 * b is the LCM */
37
37
     if ((res = mp_div(a, &t1, &t2, NULL)) != MP_OKAY) {
38
 
        goto __T;
 
38
        goto LBL_T;
39
39
     }
40
40
     res = mp_mul(b, &t2, c);
41
41
  } else {
42
42
     /* store quotient in t2 such that t2 * a is the LCM */
43
43
     if ((res = mp_div(b, &t1, &t2, NULL)) != MP_OKAY) {
44
 
        goto __T;
 
44
        goto LBL_T;
45
45
     }
46
46
     res = mp_mul(a, &t2, c);
47
47
  }
49
49
  /* fix the sign to positive */
50
50
  c->sign = MP_ZPOS;
51
51
 
52
 
__T:
 
52
LBL_T:
53
53
  mp_clear_multi (&t1, &t2, NULL);
54
54
  return res;
55
55
}