[Git][NTPsec/ntpsec][master] Initialize `aes_key` variable as an array of bytes

Gary E. Miller (@garyedmundsmiller) gitlab at mg.gitlab.com
Tue Apr 22 02:17:54 UTC 2025



Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
98a3d24f by Matt Selsky at 2025-04-21T21:36:22-04:00
Initialize `aes_key` variable as an array of bytes

Fedora 42 x86_64 ships with a gcc 15.x snapshot that produces the following warning:
```
../../tests/libntp/authkeys.c:12:35: error: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (17 chars into 16 available) [-Werror=unterminated-string-initialization]
   12 | const unsigned char aes_key[16] = "0123456789abcdef";
      |
```

We could use `__attribute__((nonstring))` to annotate the variable, but this is
only supported by gcc and not by clang.

I've tested this change on Fedora 42 x86_64 with gcc 15.0.1 and clang 20.1.2
and there were no errors/warnings, and all tests passed.

NTPsec/ntpsec#847

- - - - -


1 changed file:

- tests/libntp/authkeys.c


Changes:

=====================================
tests/libntp/authkeys.c
=====================================
@@ -9,7 +9,10 @@
 
 #include "ntp.h"
 
-const unsigned char aes_key[16] = "0123456789abcdef";
+const unsigned char aes_key[16] = {
+	'0', '1', '2', '3', '4', '5', '6', '7',
+	'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
+};
 
 TEST_GROUP(authkeys);
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/98a3d24fe66f9c0f226669e6be64ab1b79fa9e13

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/98a3d24fe66f9c0f226669e6be64ab1b79fa9e13
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20250422/ec88d215/attachment.htm>


More information about the vc mailing list