Skip to content

Commit

Permalink
Suppress clang-analyzer warnings
Browse files Browse the repository at this point in the history
This suppresses a couple of dead assignments and unlikely null pointer
dereferences.

Signed-off-by: Daiki Ueno <[email protected]>
  • Loading branch information
ueno committed Apr 16, 2024
1 parent 4f13e7e commit ab88cb3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ static CK_RV p11prov_interface_init(P11PROV_MODULE *mctx)
return CKR_HOST_MEMORY;
}

ret = CKR_FUNCTION_NOT_SUPPORTED;
intf->GetInterface = dlsym(mctx->dlhandle, "C_GetInterface");
if (!intf->GetInterface) {
char *err = dlerror();
Expand Down
1 change: 0 additions & 1 deletion src/objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,6 @@ static int p11prov_obj_export_public_ec_key(P11PROV_OBJ *obj,
switch (key_type) {
case CKK_EC:
attrs[0].type = CKA_P11PROV_CURVE_NID;
nattr = 1;
rv = get_public_attrs(obj, attrs, 1);
if (rv != CKR_OK) {
P11PROV_raise(obj->ctx, rv, "Failed to get EC key curve nid");
Expand Down
14 changes: 9 additions & 5 deletions src/signature.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,9 @@ static CK_RV p11prov_sig_operate(P11PROV_SIG_CTX *sigctx, unsigned char *sig,
if (sigctx->operation == CKF_VERIFY) {
return CKR_ARGUMENTS_BAD;
}
return p11prov_sig_get_sig_size(sigctx, siglen);
if (siglen) {
return p11prov_sig_get_sig_size(sigctx, siglen);
}
}

if (sigctx->operation == CKF_SIGN && sigctx->mechtype == CKM_RSA_X_509) {
Expand Down Expand Up @@ -1042,9 +1044,11 @@ static int p11prov_sig_digest_final(P11PROV_SIG_CTX *sigctx, unsigned char *sig,
if (sigctx->operation == CKF_VERIFY) {
goto done;
}
ret = p11prov_sig_get_sig_size(sigctx, siglen);
if (ret == CKR_OK) {
result = RET_OSSL_OK;
if (siglen) {
ret = p11prov_sig_get_sig_size(sigctx, siglen);
if (ret == CKR_OK) {
result = RET_OSSL_OK;
}
}
return result;
}
Expand Down Expand Up @@ -1868,7 +1872,7 @@ static int p11prov_ecdsa_digest_sign_final(void *ctx, unsigned char *sig,
{
P11PROV_SIG_CTX *sigctx = (P11PROV_SIG_CTX *)ctx;
unsigned char raw[P11PROV_MAX_RAW_ECC_SIG_SIZE];
size_t rawlen;
size_t rawlen = 0;
int ret;

/* the siglen might be uninitialized when called from openssl */
Expand Down

0 comments on commit ab88cb3

Please sign in to comment.