]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
random-util: fix compilation error
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 15 Jan 2025 16:29:04 +0000 (01:29 +0900)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 27 Jan 2025 18:04:50 +0000 (19:04 +0100)
Fixes the following error:
```
../src/basic/random-util.c: In function "fallback_random_bytes":
../src/basic/random-util.c:45:26: error: initializer-string for array of "char" is too long [-Werror=unterminated-string-initialization]
   45 |                 .label = "systemd fallback random bytes v1",
      |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
```

(cherry picked from commit e722fe74ca5e00d3c8a5f85342b75c40ace051f9)

src/basic/random-util.c

index 4069b290d55caa7dc2c3b863178de12dde994011..7602d8c5762a49c539abe3f6d491feab2d5c53aa 100644 (file)
@@ -45,7 +45,6 @@ static void fallback_random_bytes(void *p, size_t n) {
                 uint8_t auxval[16];
         } state = {
                 /* Arbitrary domain separation to prevent other usage of AT_RANDOM from clashing. */
-                .label = "systemd fallback random bytes v1",
                 .call_id = fallback_counter++,
                 .stamp_mono = now(CLOCK_MONOTONIC),
                 .stamp_real = now(CLOCK_REALTIME),
@@ -53,6 +52,7 @@ static void fallback_random_bytes(void *p, size_t n) {
                 .tid = gettid(),
         };
 
+        memcpy(state.label, "systemd fallback random bytes v1", sizeof(state.label));
 #if HAVE_SYS_AUXV_H
         memcpy(state.auxval, ULONG_TO_PTR(getauxval(AT_RANDOM)), sizeof(state.auxval));
 #endif