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

Commit7c058c6

Browse files
committed
Prevent negative zero from being created via BN bit functions.
Both BN_clear_bit() and BN_mask_bits() can create zero values - in bothcases ensure that the negative sign is correctly handled if the valuebecomes zero.Thanks to Guido Vranken for providing a reproducer.Fixes oss-fuzz #67901ok tb@
1 parented75954 commit7c058c6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎lib/libcrypto/bn/bn_lib.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: bn_lib.c,v 1.90 2023/07/28 10:35:14 tb Exp $ */
1+
/* $OpenBSD: bn_lib.c,v 1.91 2024/04/15 14:35:25 jsing Exp $ */
22
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
33
* All rights reserved.
44
*
@@ -438,6 +438,9 @@ BN_clear_bit(BIGNUM *a, int n)
438438

439439
a->d[i] &= (~(((BN_ULONG)1) <<j));
440440
bn_correct_top(a);
441+
442+
BN_set_negative(a,a->neg);
443+
441444
return (1);
442445
}
443446
LCRYPTO_ALIAS(BN_clear_bit);
@@ -476,6 +479,9 @@ BN_mask_bits(BIGNUM *a, int n)
476479
a->d[w] &= ~(BN_MASK2 <<b);
477480
}
478481
bn_correct_top(a);
482+
483+
BN_set_negative(a,a->neg);
484+
479485
return (1);
480486
}
481487
LCRYPTO_ALIAS(BN_mask_bits);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp