svn commit: lorikeet r708 - in trunk/heimdal/lib/des: . imath
lha at samba.org
lha at samba.org
Thu Jan 11 20:27:22 GMT 2007
Author: lha
Date: 2007-01-11 20:27:22 +0000 (Thu, 11 Jan 2007)
New Revision: 708
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=lorikeet&rev=708
Log:
update to current heimdal, fixed bug in s_udiv
Modified:
trunk/heimdal/lib/des/ChangeLog
trunk/heimdal/lib/des/imath/imath.c
Changeset:
Modified: trunk/heimdal/lib/des/ChangeLog
===================================================================
--- trunk/heimdal/lib/des/ChangeLog 2007-01-11 04:01:04 UTC (rev 707)
+++ trunk/heimdal/lib/des/ChangeLog 2007-01-11 20:27:22 UTC (rev 708)
@@ -1,3 +1,25 @@
+2007-01-11 Love Hörnquist Åstrand <lha at it.su.se>
+
+ * imath/imath.c: Update to imath-1.8 from Michael Fromberger
+
+ Fixed a bug in s_udiv() affecting the computation of quotient
+ digits. Thanks to Love Åstrand for isolating this bug. Also in
+ this release, defining USELLONG=Y or USELLONG=N on the command
+ line for make will switch support for the "long long" data type on
+ or off without having to edit the Makefile. The default is still
+ to permit use of "long long", even though the type is not standard
+ ANSI C90.
+
+ * imath/imath.c (s_udiv): Allocate one more for q, remove debug
+ printfs
+
+2007-01-10 Love Hörnquist Åstrand <lha at it.su.se>
+
+ * imath/imath.c (s_udiv): make a copy of a and b before we start
+ to make sure there is something un-tainted to print in cause of
+ failure. XXX remove this delta
+ (s_embar): make static
+
2007-01-09 Love Hörnquist Åstrand <lha at it.su.se>
* rsa.c: Correct the test if the rsa is a complete RSA private
Modified: trunk/heimdal/lib/des/imath/imath.c
===================================================================
--- trunk/heimdal/lib/des/imath/imath.c 2007-01-11 04:01:04 UTC (rev 707)
+++ trunk/heimdal/lib/des/imath/imath.c 2007-01-11 20:27:22 UTC (rev 708)
@@ -2,7 +2,7 @@
Name: imath.c
Purpose: Arbitrary precision integer arithmetic routines.
Author: M. J. Fromberger <http://www.dartmouth.edu/~sting/>
- Info: $Id: imath.c,v 1.9 2007/01/11 03:59:34 lha Exp $
+ Info: $Id: imath.c,v 1.10 2007/01/11 20:23:15 lha Exp $
Copyright (C) 2002 Michael J. Fromberger, All Rights Reserved.
@@ -34,7 +34,6 @@
#endif
#include <stdlib.h>
-#include <stdio.h>
#include <string.h>
#include <ctype.h>
@@ -2994,7 +2993,7 @@
k = s_norm(a, b);
ua = MP_USED(a); ub = MP_USED(b); btop = b->digits[ub - 1];
- if((res = mp_int_init_size(&q, ua + 1)) != MP_OK) return res;
+ if((res = mp_int_init_size(&q, ua)) != MP_OK) return res;
if((res = mp_int_init_size(&t, ua + 1)) != MP_OK) goto CLEANUP;
da = MP_DIGITS(a);
@@ -3012,7 +3011,7 @@
r.digits -= 1;
r.used += 1;
- if(++skip > 1)
+ if(++skip > 1 && qpos > 0)
q.digits[qpos++] = 0;
CLAMP(&r);
@@ -3021,15 +3020,19 @@
mp_word pfx = r.digits[r.used - 1];
mp_word qdigit;
- if(r.used > 1 && (pfx < btop || r.digits[r.used - 2] == 0)) {
+ if(r.used > 1 && pfx <= btop) {
pfx <<= MP_DIGIT_BIT / 2;
pfx <<= MP_DIGIT_BIT / 2;
pfx |= r.digits[r.used - 2];
}
qdigit = pfx / btop;
- if(qdigit > MP_DIGIT_MAX)
- qdigit = 1;
+ if(qdigit > MP_DIGIT_MAX) {
+ if(qdigit & MP_DIGIT_MAX)
+ qdigit = MP_DIGIT_MAX;
+ else
+ qdigit = 1;
+ }
s_dbmul(MP_DIGITS(b), (mp_digit) qdigit, t.digits, ub);
t.used = ub + 1; CLAMP(&t);
@@ -3046,7 +3049,7 @@
skip = 0;
}
}
-
+
/* Put quotient digits in the correct order, and discard extra zeroes */
q.used = qpos;
REV(mp_digit, q.digits, qpos);
More information about the samba-cvs
mailing list