From 91ec670d3f6399510995dedbf99dca2e7e9bd2d8 Mon Sep 17 00:00:00 2001
From: Felix Conway <felix.conway@arm.com>
Date: Thu, 12 Jun 2025 11:28:56 +0100
Subject: [PATCH 2/2] Replace __attribute__((nonstring)) with macro
 MBEDTLS_ATTRIBUTE_UNTERMINATED_STRING

This macro applies __attribute__((nonstring)) when using a compiler that supports it

Upstream-Status: Backport [https://github.com/Mbed-TLS/mbedtls/pull/10216]
Signed-off-by: Felix Conway <felix.conway@arm.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 library/ssl_tls13_keys.c | 2 +-
 library/ssl_tls13_keys.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/library/ssl_tls13_keys.c b/library/ssl_tls13_keys.c
index 375814c..621a7d5 100644
--- a/library/ssl_tls13_keys.c
+++ b/library/ssl_tls13_keys.c
@@ -82,7 +82,7 @@ struct mbedtls_ssl_tls13_labels_struct const mbedtls_ssl_tls13_labels =
  */
 
 /* 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 ";
+static const char tls13_label_prefix[6] MBEDTLS_ATTRIBUTE_UNTERMINATED_STRING = "tls13 ";
 
 #define SSL_TLS1_3_KEY_SCHEDULE_HKDF_LABEL_LEN(label_len, context_len) \
     (2                     /* expansion length           */ \
diff --git a/library/ssl_tls13_keys.h b/library/ssl_tls13_keys.h
index 95cde7a..3aa94d7 100644
--- a/library/ssl_tls13_keys.h
+++ b/library/ssl_tls13_keys.h
@@ -42,7 +42,7 @@
 
 /* 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] __attribute__ ((nonstring));
+    const unsigned char name    [sizeof(string) - 1] MBEDTLS_ATTRIBUTE_UNTERMINATED_STRING;
 
 union mbedtls_ssl_tls13_labels_union {
     MBEDTLS_SSL_TLS1_3_LABEL_LIST
