]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Define and use NONSTRING attribute. master use-has_attribute
authorNiels Möller <nisse@lysator.liu.se>
Tue, 12 May 2026 18:21:36 +0000 (20:21 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Tue, 12 May 2026 18:21:36 +0000 (20:21 +0200)
ChangeLog
aclocal.m4
base16-encode.c
base64-encode.c
base64url-encode.c
blowfish-bcrypt.c
tools/pkcs1-conv.c

index b7979cf2e78ad835cf244512f73cea17e8cde561..831788e27d5c3e05114ab4e41acce1653bfac75a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2026-05-12  Niels Möller  <nisse@lysator.liu.se>
 
+       Avoid gcc-15 warnings on missing NUL terminators. Based on patch
+       by Georg Sauthoff:
+       * aclocal.m4 (NETTLE_C_ATTRIBUTES): Define NONSTRING attribute.
+       * base16-encode.c (hex_digits): Declare as NONSTRING.
+       * base64-encode.c (base64_encode_table): Likewise.
+       * blowfish-bcrypt.c (radix64_encode_table): Likewise.
+       * tools/pkcs1-conv.c (pem_start_pattern, pem_end_pattern, pem_trailer_pattern): Likewise.
+
        * nettle-types.h (_NETTLE_ATTRIBUTE_PURE): Change preprocessor
        conditionals to use __has_attribute.
        (_NETTLE_ATTRIBUTE_DEPRECATED): Deleted, no longer used.
index 434e819da524e87af5a6adafcd2124db2dfd59b6..602c5bad62812b7cb8c7ef8e9350e75eb6f7732d 100644 (file)
@@ -49,6 +49,11 @@ AC_DEFUN([NETTLE_C_ATTRIBUTES],
 # else
 #  define CONSTRUCTOR
 # endif
+# if __has_attribute (__nonstring__)
+#  define NONSTRING __attribute__ ((__nonstring__))
+# else
+#  define NONSTRING
+# endif
 # if __has_attribute (__noreturn__)
 #  define NORETURN __attribute__ ((__noreturn__))
 # else
@@ -66,6 +71,7 @@ AC_DEFUN([NETTLE_C_ATTRIBUTES],
 # endif
 #else /* !_has_attribute */
 # define CONSTRUCTOR
+# define NONSTRING
 # define NORETURN
 # define PRINTF_STYLE(f, a)
 # define UNUSED
index 9c7f0b1ed017c54678257c50d9f574825bc506b8..c6a4c6b929495e46ad170059365e237d7e6e7f85 100644 (file)
@@ -39,7 +39,7 @@
 
 
 static const uint8_t
-hex_digits[16] = "0123456789abcdef";
+hex_digits[16] NONSTRING = "0123456789abcdef";
 
 #define DIGIT(x) (hex_digits[(x) & 0xf])
 
index ee1ec149101306cf0698510501163847f3cfe662..6bb55782c8875113dfc24a1e62546dff5a4fcb08 100644 (file)
@@ -83,7 +83,7 @@ encode_raw(const char *alphabet,
   assert(out == dst);
 }
 
-static const char base64_encode_table[64] =
+static const char base64_encode_table[64] NONSTRING =
   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
   "abcdefghijklmnopqrstuvwxyz"
   "0123456789+/";
index d30044ea8686626d83b972ce666c1ffe7fb278f3..2b78a800e4b7cfcaedebaa3c3ddb19beae3d6c81 100644 (file)
@@ -38,7 +38,7 @@
 void
 base64url_encode_init(struct base64_encode_ctx *ctx)
 {
-  static const char base64url_encode_table[64] =
+  static const char base64url_encode_table[64] NONSTRING =
     "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     "abcdefghijklmnopqrstuvwxyz"
     "0123456789-_";
index 385503ac8c7f8212d697a82572bd75279ee2d711..0326f1ffb2dbede090db23133b490980953c542a 100644 (file)
@@ -70,7 +70,7 @@ static const signed char radix64_decode_table[0x100] = {
   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 };
 
-static const char radix64_encode_table[64] =
+static const char radix64_encode_table[64] NONSTRING =
   "./ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     "abcdefghijklmnopqrstuvwxyz"
     "0123456789";
index f6b044d22bc9d7f98fc370e9e13d2f69014e1a27..68bb67d1826f754b7083f3da538ba690ebd4c001 100644 (file)
@@ -117,13 +117,13 @@ read_file(struct nettle_buffer *buffer, FILE *f)
 }
 
 static const uint8_t
-pem_start_pattern[11] = "-----BEGIN ";
+pem_start_pattern[11] NONSTRING = "-----BEGIN ";
 
 static const uint8_t
-pem_end_pattern[9] = "-----END ";
+pem_end_pattern[9] NONSTRING = "-----END ";
 
 static const uint8_t
-pem_trailer_pattern[5] = "-----";
+pem_trailer_pattern[5] NONSTRING = "-----";
 
 static const char
 pem_ws[33] = {