Skip to content

Commit

Permalink
Remove unnecessary assert in PK11MessageDigest.c
Browse files Browse the repository at this point in the history
This ASSERT_OUTOFMEM(env) is incorrect for two reasons:

 1. When JSS_RefByteArray detects a zero-length result, it returns
    false but doesn't throw an exception. It is up to the caller to
    handle that as they wish. In our case, we can safely skip the
    PK11_DigestOp call.
 2. When length < offset+len (and JSS_RefByteArray exits
    successfully), we won't have thrown an exception.

This only shows up in debug builds; release builds aren't affected.

Signed-off-by: Alexander Scheel <[email protected]>
  • Loading branch information
cipherboy committed Oct 2, 2019
1 parent dd56677 commit 0fd96dd
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion org/mozilla/jss/pkcs11/PK11MessageDigest.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ Java_org_mozilla_jss_pkcs11_PK11MessageDigest_update

if (!JSS_RefByteArray(env, inbufBA, &bytes, &length) ||
length < offset+len) {
ASSERT_OUTOFMEM(env);
goto finish;
}

Expand Down

0 comments on commit 0fd96dd

Please sign in to comment.