Blame SOURCES/tpm2-pkcs11-gcc11.patch

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