From 008afda06f22d472807d24846c8cf442424d1def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Thu, 11 Jan 2007 03:55:51 +0000 Subject: [PATCH] (s_udiv): Allocate one more for q, remove debug printfs git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19830 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/des/imath/imath.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/des/imath/imath.c b/lib/des/imath/imath.c index 9d192d752..e4da3d311 100755 --- a/lib/des/imath/imath.c +++ b/lib/des/imath/imath.c @@ -2998,7 +2998,7 @@ static mp_result s_udiv(mp_int a, mp_int b) 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)) != MP_OK) return res; + if((res = mp_int_init_size(&q, ua + 1)) != MP_OK) return res; if((res = mp_int_init_size(&t, ua + 1)) != MP_OK) goto CLEANUP; if((res = mp_int_init_copy(&ac, a)) != MP_OK) goto CLEANUP; @@ -3013,16 +3013,7 @@ static mp_result s_udiv(mp_int a, mp_int b) /* Solve for quotient digits, store in q.digits in reverse order */ while(r.digits >= da) { - if (qpos > q.alloc) { - char buf[1024]; - printf("qpos = %d q.alloc = %d ua = %d\n", - (int)qpos, (int)q.alloc, (int)ua); - mp_int_to_string(&ac, 10, buf, sizeof(buf)); - printf("ac = %s\n", buf); - mp_int_to_string(&bc, 10, buf, sizeof(buf)); - printf("bc = %s\n", buf); - assert(qpos <= q.alloc); - } + assert(qpos <= q.alloc); if(s_ucmp(b, &r) > 0) { r.digits -= 1;