|
|
551b01 |
diff --git a/src/lib/slot.c b/src/lib/slot.c
|
|
|
551b01 |
index b3c7c82..f0a4f2e 100644
|
|
|
551b01 |
--- a/src/lib/slot.c
|
|
|
551b01 |
+++ b/src/lib/slot.c
|
|
|
551b01 |
@@ -120,7 +120,9 @@ CK_RV slot_get_info (CK_SLOT_ID slot_id, CK_SLOT_INFO *info) {
|
|
|
551b01 |
}
|
|
|
551b01 |
|
|
|
551b01 |
str_padded_copy(info->manufacturerID, token_info.manufacturerID, sizeof(info->manufacturerID));
|
|
|
551b01 |
- str_padded_copy(info->slotDescription, token_info.label, sizeof(info->slotDescription));
|
|
|
551b01 |
+ size_t to_copy = sizeof (token_info.label);
|
|
|
551b01 |
+ to_copy = (to_copy > sizeof (info->slotDescription)) ? sizeof (info->slotDescription) : to_copy;
|
|
|
551b01 |
+ str_padded_copy(info->slotDescription, token_info.label, to_copy);
|
|
|
551b01 |
|
|
|
551b01 |
info->hardwareVersion = token_info.hardwareVersion;
|
|
|
551b01 |
info->firmwareVersion = token_info.firmwareVersion;
|
|
|
551b01 |
diff --git a/src/lib/tpm.c b/src/lib/tpm.c
|
|
|
551b01 |
index 90fb3c3..1bce3ac 100644
|
|
|
551b01 |
--- a/src/lib/tpm.c
|
|
|
551b01 |
+++ b/src/lib/tpm.c
|
|
|
551b01 |
@@ -732,7 +732,9 @@ CK_RV tpm_get_token_info (tpm_ctx *ctx, CK_TOKEN_INFO *info) {
|
|
|
551b01 |
unsigned char manufacturerID[sizeof(UINT32)+1] = {0}; // 4 bytes + '\0' as temp storage
|
|
|
551b01 |
UINT32 manufacturer = ntohl(tpmProperties[TPM2_PT_MANUFACTURER - TPM2_PT_FIXED].value);
|
|
|
551b01 |
memcpy(manufacturerID, (unsigned char*) &manufacturer, sizeof(uint32_t));
|
|
|
551b01 |
- str_padded_copy(info->manufacturerID, manufacturerID, sizeof(info->manufacturerID));
|
|
|
551b01 |
+ size_t to_copy = sizeof (manufacturerID);
|
|
|
551b01 |
+ to_copy = (to_copy > sizeof (info->manufacturerID)) ? sizeof (info->manufacturerID) : to_copy;
|
|
|
551b01 |
+ str_padded_copy(info->manufacturerID, manufacturerID, to_copy);
|
|
|
551b01 |
|
|
|
551b01 |
// Map human readable Manufacturer String, if available,
|
|
|
551b01 |
// otherwise 4 byte ID was already padded and will be used.
|
|
|
551b01 |
diff --git a/test/unit/test_twist.c b/test/unit/test_twist.c
|
|
|
551b01 |
index ec66f69..54ec883 100644
|
|
|
551b01 |
--- a/test/unit/test_twist.c
|
|
|
551b01 |
+++ b/test/unit/test_twist.c
|
|
|
551b01 |
@@ -311,6 +311,8 @@ void test_twistbin_aappend_null_array(void **state) {
|
|
|
551b01 |
}
|
|
|
551b01 |
|
|
|
551b01 |
void test_twistbin_aappend_twist_null(void **state) {
|
|
|
551b01 |
+#pragma GCC diagnostic push
|
|
|
551b01 |
+#pragma GCC diagnostic ignored "-Wstringop-overflow="
|
|
|
551b01 |
(void) state;
|
|
|
551b01 |
|
|
|
551b01 |
twist expected = twist_new("foo");
|
|
|
551b01 |
@@ -322,6 +324,7 @@ void test_twistbin_aappend_twist_null(void **state) {
|
|
|
551b01 |
assert_ptr_equal((void * )actual, (void * )expected);
|
|
|
551b01 |
|
|
|
551b01 |
twist_free(actual);
|
|
|
551b01 |
+#pragma GCC diagnostic pop
|
|
|
551b01 |
}
|
|
|
551b01 |
|
|
|
551b01 |
void test_twistbin_create_null(void **state) {
|