Add __attribute__ ((nonstring)) to remove unterminated-string-initialization warning

Signed-off-by: Felix Conway <felix.conway@arm.com>
This commit is contained in:
Felix Conway 2025-06-11 16:04:06 +01:00 committed by Ari Weiler-Ofek
parent 7c536dab54
commit 79b513894a
5 changed files with 10 additions and 5 deletions

View File

@ -80,7 +80,8 @@ struct mbedtls_ssl_tls13_labels_struct const mbedtls_ssl_tls13_labels =
* the HkdfLabel structure on success.
*/
static const char tls13_label_prefix[6] = "tls13 ";
/* We need to tell the compiler that we meant to leave out the null character. */
static const char tls13_label_prefix[6] __attribute__ ((nonstring)) = "tls13 ";
#define SSL_TLS1_3_KEY_SCHEDULE_HKDF_LABEL_LEN(label_len, context_len) \
(2 /* expansion length */ \

View File

@ -40,8 +40,9 @@
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
/* We need to tell the compiler that we meant to leave out the null character. */
#define MBEDTLS_SSL_TLS1_3_LABEL(name, string) \
const unsigned char name [sizeof(string) - 1];
const unsigned char name [sizeof(string) - 1] __attribute__ ((nonstring));
union mbedtls_ssl_tls13_labels_union {
MBEDTLS_SSL_TLS1_3_LABEL_LIST

View File

@ -25,7 +25,8 @@ int psa_aead_encrypt_decrypt_main(void)
uint8_t encrypt[BUFFER_SIZE] = { 0 };
uint8_t decrypt[BUFFER_SIZE] = { 0 };
const uint8_t plaintext[] = "Hello World!";
const uint8_t key_bytes[32] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
/* We need to tell the compiler that we meant to leave out the null character. */
const uint8_t key_bytes[32] __attribute__ ((nonstring)) = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
uint8_t nonce[PSA_AEAD_NONCE_LENGTH(PSA_KEY_TYPE_AES, PSA_ALG_CCM)];
size_t nonce_length = sizeof(nonce);
size_t ciphertext_length;

View File

@ -25,7 +25,8 @@ int psa_cipher_encrypt_decrypt_main(void)
uint8_t original[BUFFER_SIZE] = { 0 };
uint8_t encrypt[BUFFER_SIZE] = { 0 };
uint8_t decrypt[BUFFER_SIZE] = { 0 };
const uint8_t key_bytes[32] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
/* We need to tell the compiler that we meant to leave out the null character. */
const uint8_t key_bytes[32] __attribute__ ((nonstring)) = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
size_t encrypted_length;
size_t decrypted_length;

View File

@ -37,7 +37,8 @@ void ssl_decrypt_null(int hash_id)
mbedtls_ssl_write_version(rec_good.ver,
MBEDTLS_SSL_TRANSPORT_STREAM,
version);
const char sample_plaintext[3] = "ABC";
/* We need to tell the compiler that we meant to leave out the null character. */
const char sample_plaintext[3] __attribute__ ((nonstring)) = "ABC";
mbedtls_ssl_context ssl;
mbedtls_ssl_init(&ssl);
uint8_t *buf = NULL;