Fix all clang scan-build warnings

This commit is contained in:
Trevor Bentley
2017-09-27 11:28:39 +02:00
parent 90209997cc
commit 9a7ccf48fa
7 changed files with 18 additions and 10 deletions
+2
View File
@@ -222,8 +222,10 @@ EXIT:
return rc; return rc;
ERROR_EXIT: ERROR_EXIT:
if (key) {
des_destroy_key(*key); des_destroy_key(*key);
*key = NULL; *key = NULL;
}
goto EXIT; goto EXIT;
+3 -1
View File
@@ -543,7 +543,9 @@ int SSH_write_X509(FILE *fp, X509 *x) {
rsa = EVP_PKEY_get1_RSA(pkey); rsa = EVP_PKEY_get1_RSA(pkey);
set_component(n, rsa->n, RSA_size(rsa)); if (!set_component(n, rsa->n, RSA_size(rsa))) {
break;
}
uint32_t bytes = BN_num_bytes(rsa->n); uint32_t bytes = BN_num_bytes(rsa->n);
char len_buf[5]; char len_buf[5];
+1 -1
View File
@@ -173,7 +173,7 @@ CK_RV do_create_empty_cert(CK_BYTE_PTR in, CK_ULONG in_len, CK_BBOOL is_rsa,
// Manually set a signature (same reason as before) // Manually set a signature (same reason as before)
ASN1_BIT_STRING_set_bit(cert->signature, 8, 1); ASN1_BIT_STRING_set_bit(cert->signature, 8, 1);
ASN1_BIT_STRING_set(cert->signature, "\x00", 1); ASN1_BIT_STRING_set(cert->signature, (unsigned char*)"\x00", 1);
len = i2d_X509(cert, NULL); len = i2d_X509(cert, NULL);
if (len < 0) if (len < 0)
-2
View File
@@ -258,8 +258,6 @@ void strip_DER_encoding_from_ECSIG(CK_BYTE_PTR data, CK_ULONG_PTR len) {
data_ptr++; data_ptr++;
memcpy(buf_ptr, data_ptr, elem_len); memcpy(buf_ptr, data_ptr, elem_len);
data_ptr += elem_len;
buf_ptr += elem_len;
*len = sig_halflen * 2; *len = sig_halflen * 2;
memcpy(data, buf, *len); memcpy(data, buf, *len);
+6
View File
@@ -215,6 +215,11 @@ CK_DEFINE_FUNCTION(CK_RV, C_GetSlotList)(
return CKR_OK; return CKR_OK;
} }
if (!pulCount) {
DOUT;
return CKR_ARGUMENTS_BAD;
}
if ((tokenPresent && *pulCount < n_slots_with_token) || (!tokenPresent && *pulCount < n_slots)) { if ((tokenPresent && *pulCount < n_slots_with_token) || (!tokenPresent && *pulCount < n_slots)) {
DBG("Buffer too small: needed %lu, provided %lu", n_slots, *pulCount); DBG("Buffer too small: needed %lu, provided %lu", n_slots, *pulCount);
return CKR_BUFFER_TOO_SMALL; return CKR_BUFFER_TOO_SMALL;
@@ -1214,6 +1219,7 @@ CK_DEFINE_FUNCTION(CK_RV, C_DestroyObject)(
rv = delete_cert(cert_id); rv = delete_cert(cert_id);
if (rv != CKR_OK) { if (rv != CKR_OK) {
free(obj_ptr);
DBG("Unable to delete certificate data"); DBG("Unable to delete certificate data");
return CKR_FUNCTION_FAILED; return CKR_FUNCTION_FAILED;
} }
+3 -3
View File
@@ -32,16 +32,16 @@
#include "pkcs11.h" #include "pkcs11.h"
#include <string.h> #include <string.h>
static const CK_UTF8CHAR_PTR slot_manufacturer = "Yubico"; static const CK_UTF8CHAR_PTR slot_manufacturer = (const CK_UTF8CHAR_PTR)"Yubico";
static const CK_FLAGS slot_flags = CKF_TOKEN_PRESENT | CKF_HW_SLOT; static const CK_FLAGS slot_flags = CKF_TOKEN_PRESENT | CKF_HW_SLOT;
static const CK_VERSION slot_version = {1, 0}; static const CK_VERSION slot_version = {1, 0};
CK_RV YUBICO_get_slot_manufacturer(CK_UTF8CHAR_PTR str, CK_ULONG len) { CK_RV YUBICO_get_slot_manufacturer(CK_UTF8CHAR_PTR str, CK_ULONG len) {
if (strlen(slot_manufacturer) > len) if (strlen((const char*)slot_manufacturer) > len)
return CKR_BUFFER_TOO_SMALL; return CKR_BUFFER_TOO_SMALL;
memcpy(str, slot_manufacturer, strlen(slot_manufacturer)); memcpy(str, slot_manufacturer, strlen((const char*)slot_manufacturer));
return CKR_OK; return CKR_OK;
} }
+1 -1
View File
@@ -372,7 +372,7 @@ CK_RV YUBICO_token_change_pin(ykpiv_state *state, CK_USER_TYPE user_type, CK_UTF
DBG("TODO implement other users pin change"); DBG("TODO implement other users pin change");
return CKR_FUNCTION_FAILED; return CKR_FUNCTION_FAILED;
} }
res = ykpiv_change_pin(state, pOldPin, ulOldLen, pNewPin, ulNewLen, &tries); res = ykpiv_change_pin(state, (const char*)pOldPin, ulOldLen, (const char*)pNewPin, ulNewLen, &tries);
switch (res) { switch (res) {
case YKPIV_OK: case YKPIV_OK:
return CKR_OK; return CKR_OK;