Skip to content

Commit e1e8f3c

Browse files
committed
raise when EC_POINT_cmp or EC_GROUP_cmp error instead of returning true
1 parent de8a644 commit e1e8f3c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

ext/openssl/ossl_pkey_ec.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -860,10 +860,11 @@ static VALUE ossl_ec_group_eql(VALUE a, VALUE b)
860860
GetECGroup(a, group1);
861861
GetECGroup(b, group2);
862862

863-
if (EC_GROUP_cmp(group1, group2, ossl_bn_ctx) == 1)
864-
return Qfalse;
865-
866-
return Qtrue;
863+
switch (EC_GROUP_cmp(group1, group2, ossl_bn_ctx)) {
864+
case 0: return Qtrue;
865+
case 1: return Qfalse;
866+
default: ossl_raise(eEC_GROUP, "EC_GROUP_cmp");
867+
}
867868
}
868869

869870
/*
@@ -1424,10 +1425,13 @@ static VALUE ossl_ec_point_eql(VALUE a, VALUE b)
14241425
GetECPoint(b, point2);
14251426
GetECGroup(group_v1, group);
14261427

1427-
if (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx) == 1)
1428-
return Qfalse;
1428+
switch (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx)) {
1429+
case 0: return Qtrue;
1430+
case 1: return Qfalse;
1431+
default: ossl_raise(eEC_POINT, "EC_POINT_cmp");
1432+
}
14291433

1430-
return Qtrue;
1434+
UNREACHABLE;
14311435
}
14321436

14331437
/*

0 commit comments

Comments
 (0)