diff options
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/seedrng.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/util-linux/seedrng.c b/util-linux/seedrng.c index 49b9ab54b..5735dc059 100644 --- a/util-linux/seedrng.c +++ b/util-linux/seedrng.c | |||
@@ -21,7 +21,7 @@ | |||
21 | */ | 21 | */ |
22 | 22 | ||
23 | //config:config SEEDRNG | 23 | //config:config SEEDRNG |
24 | //config: bool "seedrng (2.1 kb)" | 24 | //config: bool "seedrng (2 kb)" |
25 | //config: default y | 25 | //config: default y |
26 | //config: help | 26 | //config: help |
27 | //config: Seed the kernel RNG from seed files, meant to be called | 27 | //config: Seed the kernel RNG from seed files, meant to be called |
@@ -173,8 +173,6 @@ static int seed_from_file_if_exists(const char *filename, int dfd, bool credit, | |||
173 | int seedrng_main(int argc, char *argv[]) MAIN_EXTERNALLY_VISIBLE; | 173 | int seedrng_main(int argc, char *argv[]) MAIN_EXTERNALLY_VISIBLE; |
174 | int seedrng_main(int argc UNUSED_PARAM, char *argv[]) | 174 | int seedrng_main(int argc UNUSED_PARAM, char *argv[]) |
175 | { | 175 | { |
176 | static const char seedrng_prefix[] = "SeedRNG v1 Old+New Prefix"; | ||
177 | static const char seedrng_failure[] = "SeedRNG v1 No New Seed Failure"; | ||
178 | char *seed_dir, *creditable_seed, *non_creditable_seed; | 176 | char *seed_dir, *creditable_seed, *non_creditable_seed; |
179 | int ret, fd = -1, dfd = -1, program_ret = 0; | 177 | int ret, fd = -1, dfd = -1, program_ret = 0; |
180 | uint8_t new_seed[MAX_SEED_LEN]; | 178 | uint8_t new_seed[MAX_SEED_LEN]; |
@@ -218,7 +216,7 @@ int seedrng_main(int argc UNUSED_PARAM, char *argv[]) | |||
218 | } | 216 | } |
219 | 217 | ||
220 | sha256_begin(&hash); | 218 | sha256_begin(&hash); |
221 | sha256_hash(&hash, seedrng_prefix, strlen(seedrng_prefix)); | 219 | sha256_hash(&hash, "SeedRNG v1 Old+New Prefix", 25); |
222 | clock_gettime(CLOCK_REALTIME, ×tamp); | 220 | clock_gettime(CLOCK_REALTIME, ×tamp); |
223 | sha256_hash(&hash, ×tamp, sizeof(timestamp)); | 221 | sha256_hash(&hash, ×tamp, sizeof(timestamp)); |
224 | clock_gettime(CLOCK_BOOTTIME, ×tamp); | 222 | clock_gettime(CLOCK_BOOTTIME, ×tamp); |
@@ -236,7 +234,7 @@ int seedrng_main(int argc UNUSED_PARAM, char *argv[]) | |||
236 | if (ret < 0) { | 234 | if (ret < 0) { |
237 | bb_simple_perror_msg("unable to read new seed"); | 235 | bb_simple_perror_msg("unable to read new seed"); |
238 | new_seed_len = SHA256_OUTSIZE; | 236 | new_seed_len = SHA256_OUTSIZE; |
239 | strncpy((char *)new_seed, seedrng_failure, new_seed_len); | 237 | memset(new_seed, 0, SHA256_OUTSIZE); |
240 | program_ret |= 1 << 3; | 238 | program_ret |= 1 << 3; |
241 | } | 239 | } |
242 | sha256_hash(&hash, &new_seed_len, sizeof(new_seed_len)); | 240 | sha256_hash(&hash, &new_seed_len, sizeof(new_seed_len)); |