From 22fddb16f8430d64b82a1ea08602be5e61ac203b Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 26 Jul 2025 12:41:23 +0200 Subject: [PATCH] Mark tau and sigma Chacha variables as nonstring These contain a sequence of bytes, and are not a NUL-terminated string. Help the compiler understand the intent of the code. --- src/chacha_private.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/chacha_private.h b/src/chacha_private.h index ef1b931..97e9020 100644 --- a/src/chacha_private.h +++ b/src/chacha_private.h @@ -48,8 +48,16 @@ typedef struct a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); -static const char sigma[16] = "expand 32-byte k"; -static const char tau[16] = "expand 16-byte k"; +#if defined(__has_attribute) +#if __has_attribute(__nonstring__) +#define ATTRIBUTE_NONSTRING __attribute__((__nonstring__)) +#else +#define ATTRIBUTE_NONSTRING +#endif +#endif + +static const char sigma[16] ATTRIBUTE_NONSTRING = "expand 32-byte k"; +static const char tau[16] ATTRIBUTE_NONSTRING = "expand 16-byte k"; static void chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits) -- 2.47.2