mirror of
https://github.com/cuberite/polarssl.git
synced 2025-09-24 05:00:45 -04:00
Merge pull request #10216 from felixc-arm/gcc-15-warning-dev
[Development] Fix GCC 15 warning 'Wunterminated-string-initialization'
This commit is contained in:
commit
68e531f35e
3
ChangeLog.d/unterminated-string-initialization.txt
Normal file
3
ChangeLog.d/unterminated-string-initialization.txt
Normal file
@ -0,0 +1,3 @@
|
||||
Bugfix
|
||||
* Silence spurious -Wunterminated-string-initialization warnings introduced
|
||||
by GCC 15. Fixes #9944.
|
@ -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] MBEDTLS_ATTRIBUTE_UNTERMINATED_STRING = "tls13 ";
|
||||
|
||||
#define SSL_TLS1_3_KEY_SCHEDULE_HKDF_LABEL_LEN(label_len, context_len) \
|
||||
(2 /* expansion length */ \
|
||||
|
@ -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] MBEDTLS_ATTRIBUTE_UNTERMINATED_STRING;
|
||||
|
||||
union mbedtls_ssl_tls13_labels_union {
|
||||
MBEDTLS_SSL_TLS1_3_LABEL_LIST
|
||||
|
@ -4,6 +4,21 @@
|
||||
*/
|
||||
|
||||
#include "psa/crypto.h"
|
||||
/*
|
||||
* Temporary hack: psasim’s Makefile only does:
|
||||
* -Itests/psa-client-server/psasim/include
|
||||
* -I$(MBEDTLS_ROOT_PATH)/include
|
||||
* -I$(MBEDTLS_ROOT_PATH)/tf-psa-crypto/include
|
||||
* -I$(MBEDTLS_ROOT_PATH)/tf-psa-crypto/drivers/builtin/include
|
||||
* None of those cover tf-psa-crypto/core, so we rely on the
|
||||
* “-I$(MBEDTLS_ROOT_PATH)/include” entry plus a parent-relative
|
||||
* include "../tf-psa-crypto/core/common.h" in order to pull in common.h here,
|
||||
* which in turn gets MBEDTLS_ATTRIBUTE_UNTERMINATED_STRING (to silence the
|
||||
* new GCC-15 unterminated-string-initialization warning).
|
||||
* See GitHub issue #10223 for the proper long-term fix.
|
||||
* https://github.com/Mbed-TLS/mbedtls/issues/10223
|
||||
*/
|
||||
#include "../tf-psa-crypto/core/common.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -25,7 +40,9 @@ 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] MBEDTLS_ATTRIBUTE_UNTERMINATED_STRING =
|
||||
"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;
|
||||
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "psa/crypto.h"
|
||||
#include "../tf-psa-crypto/core/common.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -25,7 +26,9 @@ 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] MBEDTLS_ATTRIBUTE_UNTERMINATED_STRING =
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
size_t encrypted_length;
|
||||
size_t decrypted_length;
|
||||
|
||||
|
@ -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] MBEDTLS_ATTRIBUTE_UNTERMINATED_STRING = "ABC";
|
||||
mbedtls_ssl_context ssl;
|
||||
mbedtls_ssl_init(&ssl);
|
||||
uint8_t *buf = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user