Tcl Source Code

Check-in [26182f50b2]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix bug in mp_set_bit(), not affecting Tcl adtually (returning MP_VAL for some valid input)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | tommath-refactor
Files: files | file ages | folders
SHA3-256: 26182f50b29a8770999bae8384afa74a099b3b7806002738f03b56269d3ffd49
User & Date: jan.nijtmans 2019-03-08 20:44:55.638
Context
2019-03-12
21:44
Merge 8.7 check-in: 4acfc50392 user: jan.nijtmans tags: tommath-refactor
2019-03-08
20:44
Fix bug in mp_set_bit(), not affecting Tcl adtually (returning MP_VAL for some valid input) check-in: 26182f50b2 user: jan.nijtmans tags: tommath-refactor
20:40
Merge 8.7 check-in: 0fda504644 user: jan.nijtmans tags: tommath-refactor
Changes
Unified Diff Ignore Whitespace Patch
Changes to libtommath/bn_mp_get_bit.c.
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

   if (b < 0) {
      return MP_VAL;
   }

   limb = b / DIGIT_BIT;

   /*
    * Zero is a special value with the member "used" set to zero.
    * Needs to be tested before the check for the upper boundary
    * otherwise (limb >= a->used) would be true for a = 0
    */

   if (mp_iszero(a) != MP_NO) {
      return MP_NO;
   }

   if (limb >= a->used) {
      return MP_VAL;
   }

   bit = (mp_digit)(1) << (b % DIGIT_BIT);

   isset = a->dp[limb] & bit;
   return (isset != 0u) ? MP_YES : MP_NO;
}







<
<
<
<
<
<
<
<
<
<

|







23
24
25
26
27
28
29










30
31
32
33
34
35
36
37
38

   if (b < 0) {
      return MP_VAL;
   }

   limb = b / DIGIT_BIT;











   if (limb >= a->used) {
      return MP_NO;
   }

   bit = (mp_digit)(1) << (b % DIGIT_BIT);

   isset = a->dp[limb] & bit;
   return (isset != 0u) ? MP_YES : MP_NO;
}