Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d412e0

Browse files
committed
Cherry-pick security-relevant fixes from upstream imath library.
This covers alterations to buffer sizing and zeroing made between imath1.3 and imath 1.20. Valgrind Memcheck identified the buffer overrunsand reliance on uninitialized data; their exploit potential is unknown.Builds specifying --with-openssl are unaffected, because they use theOpenSSL BIGNUM facility instead of imath. Back-patch to 9.0 (allsupported versions).Security:CVE-2015-0243
1 parent11f738a commit8d412e0

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

‎contrib/pgcrypto/imath.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,8 @@ mp_int_mul(mp_int a, mp_int b, mp_int c)
818818
*/
819819
ua=MP_USED(a);
820820
ub=MP_USED(b);
821-
osize=ua+ub;
821+
osize=MAX(ua,ub);
822+
osize=4* ((osize+1) /2);
822823

823824
if (c==a||c==b)
824825
{
@@ -907,7 +908,7 @@ mp_int_sqr(mp_int a, mp_int c)
907908
CHECK(a!=NULL&&c!=NULL);
908909

909910
/* Get a temporary buffer big enough to hold the result */
910-
osize= (mp_size)2*MP_USED(a);
911+
osize= (mp_size)4*((MP_USED(a)+1) /2);
911912

912913
if (a==c)
913914
{
@@ -2605,8 +2606,8 @@ s_kmul(mp_digit *da, mp_digit *db, mp_digit *dc,
26052606
* Now we'll get t1 = a0b0 and t2 = a1b1, and subtract them out so
26062607
* that we're left with only the pieces we want: t3 = a1b0 + a0b1
26072608
*/
2608-
ZERO(t1,bot_size+1);
2609-
ZERO(t2,bot_size+1);
2609+
ZERO(t1,buf_size);
2610+
ZERO(t2,buf_size);
26102611
(void)s_kmul(da,db,t1,bot_size,bot_size);/* t1 = a0 * b0 */
26112612
(void)s_kmul(a_top,b_top,t2,at_size,bt_size);/* t2 = a1 * b1 */
26122613

@@ -2616,11 +2617,13 @@ s_kmul(mp_digit *da, mp_digit *db, mp_digit *dc,
26162617

26172618
/* Assemble the output value */
26182619
COPY(t1,dc,buf_size);
2619-
(void)s_uadd(t3,dc+bot_size,dc+bot_size,
2620-
buf_size+1,buf_size+1);
2620+
carry=s_uadd(t3,dc+bot_size,dc+bot_size,
2621+
buf_size+1,buf_size);
2622+
assert(carry==0);
26212623

2622-
(void)s_uadd(t2,dc+2*bot_size,dc+2*bot_size,
2623-
buf_size,buf_size);
2624+
carry=s_uadd(t2,dc+2*bot_size,dc+2*bot_size,
2625+
buf_size,buf_size);
2626+
assert(carry==0);
26242627

26252628
s_free(t1);/* note t2 and t3 are just internal pointers
26262629
* to t1 */
@@ -3307,7 +3310,10 @@ s_embar(mp_int a, mp_int b, mp_int m, mp_int mu, mp_int c)
33073310
dbt=db+MP_USED(b)-1;
33083311

33093312
while (last<3)
3310-
SETUP(mp_int_init_size(TEMP(last),2*umu),last);
3313+
{
3314+
SETUP(mp_int_init_size(TEMP(last),4*umu),last);
3315+
ZERO(MP_DIGITS(TEMP(last-1)),MP_ALLOC(TEMP(last-1)));
3316+
}
33113317

33123318
(void)mp_int_set_value(c,1);
33133319

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp