Skip to content

Commit

Permalink
Fix NULL ptr dereference on EC_POINT *point
Browse files Browse the repository at this point in the history
Use non-usual params of pkcs11 module will trigger a null ptr deref bug. Fix it for openssl#25493

CLA: trivial
  • Loading branch information
citypw committed Sep 20, 2024
1 parent daead12 commit 60538e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crypto/ec/ec_asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ int i2o_ECPublicKey(const EC_KEY *a, unsigned char **out)
size_t buf_len = 0;
int new_buffer = 0;

if (a == NULL) {
if (a == NULL || a->pub_key == NULL) {
ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
Expand Down
4 changes: 4 additions & 0 deletions crypto/ec/ec_oct.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point,
point_conversion_form_t form, unsigned char *buf,
size_t len, BN_CTX *ctx)
{
if (point == NULL) {
ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
if (group->meth->point2oct == 0
&& !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) {
ERR_raise(ERR_LIB_EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
Expand Down

0 comments on commit 60538e0

Please sign in to comment.