Skip to content

Warnings from GCC 15 -Wunterminated-string-initialization #9944

@billatarm

Description

@billatarm

Summary

Some of the string literals use the size of the array to specify an array of size N where N is the length of the string and so things like sizeof() will truncate the NULL byte.

Warning message Example:

/builddir/build/BUILD/mbedtls3.6-3.6.2-build/mbedtls-3.6.2/library/ssl_tls13_keys.h:20:44: error: initializer-string for array of ‘unsigned char’ is too long [-Werror=unterminated-string-initialization]
   20 |     MBEDTLS_SSL_TLS1_3_LABEL(c_hs_traffic, "c hs traffic") \

Code Examples to reproduce:

char foo[3]="foo";
printf("%s-%zu\n", foo, sizeof(foo);
foo - 3

This waring can be enabled via:
-Wunterminated-string-initialization

I have attached the build log.

build.log

System information

Mbed TLS version (number or commit id): 3.6.2
Operating system and version: F32 with gcc-15
Configuration (if not default, please attach mbedtls_config.h):
Compiler and options (if you used a pre-built binary, please indicate how you obtained it):
Additional environment information:

Expected behavior

Builds

Actual behavior

Steps to reproduce

Additional information

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

Done

Status

3.6.4 Release

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions