1
Description: fix denial of service and possible arbitrary code
2
execution via unchecked return values
3
Bug: http://rt.openssl.org/Ticket/Display.html?id=2111&user=guest&pass=guest
4
Origin: upstream, http://cvs.openssl.org/chngview?cn=18936
5
Origin: upstream, http://cvs.openssl.org/chngview?cn=19309
7
diff -Nur openssl-0.9.8k/crypto/bn/bn_div.c openssl-0.9.8k.new/crypto/bn/bn_div.c
8
--- openssl-0.9.8k/crypto/bn/bn_div.c 2008-09-14 09:42:40.000000000 -0400
9
+++ openssl-0.9.8k.new/crypto/bn/bn_div.c 2010-03-30 08:56:10.000000000 -0400
11
/* The next 2 are needed so we can do a dv->d[0]|=1 later
12
* since BN_lshift1 will only work once there is a value :-) */
15
+ if(bn_wexpand(dv,1) == NULL) goto end;
18
if (!BN_lshift(D,D,nm-nd)) goto end;
19
diff -Nur openssl-0.9.8k/crypto/bn/bn_gf2m.c openssl-0.9.8k.new/crypto/bn/bn_gf2m.c
20
--- openssl-0.9.8k/crypto/bn/bn_gf2m.c 2008-06-23 16:46:28.000000000 -0400
21
+++ openssl-0.9.8k.new/crypto/bn/bn_gf2m.c 2010-03-30 08:56:10.000000000 -0400
23
if (a->top < b->top) { at = b; bt = a; }
24
else { at = a; bt = b; }
26
- bn_wexpand(r, at->top);
27
+ if(bn_wexpand(r, at->top) == NULL)
30
for (i = 0; i < bt->top; i++)
32
diff -Nur openssl-0.9.8k/crypto/bn/bn_mul.c openssl-0.9.8k.new/crypto/bn/bn_mul.c
33
--- openssl-0.9.8k/crypto/bn/bn_mul.c 2007-11-03 16:09:29.000000000 -0400
34
+++ openssl-0.9.8k.new/crypto/bn/bn_mul.c 2010-03-30 08:56:06.000000000 -0400
35
@@ -1030,15 +1030,15 @@
41
+ if (bn_wexpand(t,k*4) == NULL) goto err;
42
+ if (bn_wexpand(rr,k*4) == NULL) goto err;
43
bn_mul_part_recursive(rr->d,a->d,b->d,
46
else /* al <= j || bl <= j */
50
+ if (bn_wexpand(t,k*2) == NULL) goto err;
51
+ if (bn_wexpand(rr,k*2) == NULL) goto err;
52
bn_mul_recursive(rr->d,a->d,b->d,
55
diff -Nur openssl-0.9.8k/crypto/ec/ec2_smpl.c openssl-0.9.8k.new/crypto/ec/ec2_smpl.c
56
--- openssl-0.9.8k/crypto/ec/ec2_smpl.c 2006-03-13 18:12:07.000000000 -0500
57
+++ openssl-0.9.8k.new/crypto/ec/ec2_smpl.c 2010-03-30 08:56:10.000000000 -0400
59
dest->poly[2] = src->poly[2];
60
dest->poly[3] = src->poly[3];
61
dest->poly[4] = src->poly[4];
62
- bn_wexpand(&dest->a, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2);
63
- bn_wexpand(&dest->b, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2);
64
+ if(bn_wexpand(&dest->a, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL)
66
+ if(bn_wexpand(&dest->b, (int)(dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL)
68
for (i = dest->a.top; i < dest->a.dmax; i++) dest->a.d[i] = 0;
69
for (i = dest->b.top; i < dest->b.dmax; i++) dest->b.d[i] = 0;
74
if (!BN_GF2m_mod_arr(&group->a, a, group->poly)) goto err;
75
- bn_wexpand(&group->a, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2);
76
+ if(bn_wexpand(&group->a, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) goto err;
77
for (i = group->a.top; i < group->a.dmax; i++) group->a.d[i] = 0;
80
if (!BN_GF2m_mod_arr(&group->b, b, group->poly)) goto err;
81
- bn_wexpand(&group->b, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2);
82
+ if(bn_wexpand(&group->b, (int)(group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) goto err;
83
for (i = group->b.top; i < group->b.dmax; i++) group->b.d[i] = 0;
86
diff -Nur openssl-0.9.8k/engines/e_ubsec.c openssl-0.9.8k.new/engines/e_ubsec.c
87
--- openssl-0.9.8k/engines/e_ubsec.c 2007-09-06 08:43:53.000000000 -0400
88
+++ openssl-0.9.8k.new/engines/e_ubsec.c 2010-03-30 08:56:10.000000000 -0400
91
if (priv_key == NULL) goto err;
92
priv_key_len = BN_num_bits(dh->p);
93
- bn_wexpand(priv_key, dh->p->top);
94
+ if(bn_wexpand(priv_key, dh->p->top) == NULL) goto err;
96
if (!BN_rand_range(priv_key, dh->p)) goto err;
97
while (BN_is_zero(priv_key));
101
pub_key_len = BN_num_bits(dh->p);
102
- bn_wexpand(pub_key, dh->p->top);
103
+ if(bn_wexpand(pub_key, dh->p->top) == NULL) goto err;
104
if(pub_key == NULL) goto err;