]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
lib: Fix Wunterminated-string-initialization warnings
authorSamuel Zeter <samuelzeter@gmail.com>
Tue, 14 Oct 2025 16:00:26 +0000 (18:00 +0200)
committerDaiki Ueno <ueno@gnu.org>
Fri, 31 Oct 2025 06:17:22 +0000 (15:17 +0900)
Building on a newer gcc version (15) results in the following warnings:

status_request.c: In function 'client_send':
status_request.c:71:33: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (6 chars into 5 available) [-Wunterminated-string-initialization]
   71 |         const uint8_t data[5] = "\x01\x00\x00\x00\x00";
      |                                 ^~~~~~~~~~~~~~~~~~~~~~
x86-common.c: In function 'check_phe_partial':
x86-common.c:342:31: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (65 chars into 64 available) [-Wunterminated-string-initialization]
  342 |         const char text[64] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
      |
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Samuel Zeter <samuelzeter@gmail.com>
Modified-by: Daiki Ueno <ueno@gnu.org>
lib/accelerated/x86/x86-common.c
lib/ext/status_request.c
lib/nettle/pk.c

index 3b779865eeef50c68fc1a3566b1e0cafc0b09e52..57144e9e0c4a32ca2e68734c14eae3defd3be2fc 100644 (file)
@@ -339,8 +339,8 @@ static int check_fast_pclmul(void)
 
 static int check_phe_partial(void)
 {
-       const char text[64] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-                             "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+       const char text[SHA1_BLOCK_SIZE + 1 /*NUL*/] =
+               "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
        uint32_t iv[5] = { 0x67452301UL, 0xEFCDAB89UL, 0x98BADCFEUL,
                           0x10325476UL, 0xC3D2E1F0UL };
 
index 8c752f50a8ead15972ff444bb6d8bd2734bed6d6..6ba57dbccea41091d8c0367cb42330d9d3980fb0 100644 (file)
@@ -68,7 +68,7 @@ typedef struct {
 static int client_send(gnutls_session_t session, gnutls_buffer_st *extdata,
                       status_request_ext_st *priv)
 {
-       const uint8_t data[5] = "\x01\x00\x00\x00\x00";
+       const uint8_t data[5] = { 0x01, 0x00, 0x00, 0x00, 0x00 };
        const int len = 5;
        int ret;
 
index cc22a670d4765bc870d575f6b808c5e3edfb3512..1cd19241c30b7f05e1c43fd097b2181db3292a17 100644 (file)
@@ -3363,11 +3363,11 @@ static int pct_test(gnutls_pk_algorithm_t algo,
        int ret;
        gnutls_datum_t sig = { NULL, 0 };
        const char const_data[20] = "onetwothreefourfive";
-       const char const_data_sha256[32] = "onetwothreefourfivesixseveneight";
+       const char const_data_sha256[32] = "onetwothreefourfivesixseveneigh";
        const char const_data_sha384[48] =
-               "onetwothreefourfivesixseveneightnineteneleventwe";
+               "onetwothreefourfivesixseveneightnineteneleventw";
        const char const_data_sha512[64] =
-               "onetwothreefourfivesixseveneightnineteneleventwelvethirteenfourt";
+               "onetwothreefourfivesixseveneightnineteneleventwelvethirteenfour";
        gnutls_datum_t ddata, tmp = { NULL, 0 };
        char gen_data[MAX_HASH_SIZE];
        gnutls_x509_spki_st spki;