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.
# 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
# endif
#else /* !_has_attribute */
# define CONSTRUCTOR
+# define NONSTRING
# define NORETURN
# define PRINTF_STYLE(f, a)
# define UNUSED
static const uint8_t
-hex_digits[16] = "0123456789abcdef";
+hex_digits[16] NONSTRING = "0123456789abcdef";
#define DIGIT(x) (hex_digits[(x) & 0xf])
assert(out == dst);
}
-static const char base64_encode_table[64] =
+static const char base64_encode_table[64] NONSTRING =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
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-_";
-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";
}
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] = {