Skip to content

Commit

Permalink
avoid potential NULL pointer deref
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnerdhair committed Jul 7, 2021
1 parent 0527170 commit 7263d78
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/firmware/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,12 @@ int cryptoMessageVerify(const CoinType *coin, const uint8_t *message,

uint8_t *cryptoHDNodePathToPubkey(const CoinType *coin,
const HDNodePathType *hdnodepath) {
if (!hdnodepath->node.has_public_key ||
hdnodepath->node.public_key.size != 33)
if (!hdnodepath ||
!hdnodepath->node.has_public_key ||
hdnodepath->node.public_key.size != 33) {
return 0;
}

static HDNode node;
if (hdnode_from_xpub(hdnodepath->node.depth, hdnodepath->node.child_num,
hdnodepath->node.chain_code.bytes,
Expand Down

0 comments on commit 7263d78

Please sign in to comment.