Rename random_get_bytes() to avoid colliding a Solaris library function that has the same name. Reported-by: Sad Clouds <cryintothebluesky@xxxxxxxxx> Reference: https://lore.kernel.org/util-linux/20201101141608.ba365cf67d92ee3973226de9@xxxxxxxxx/ Reference: https://blogs.oracle.com/solaris/solaris-random-number-generation-v2 Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- include/randutils.h | 2 +- lib/randutils.c | 6 +++--- libfdisk/src/dos.c | 2 +- libuuid/src/gen_uuid.c | 6 +++--- misc-utils/mcookie.c | 2 +- sys-utils/ipcmk.c | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/randutils.h b/include/randutils.h index 86e35f3f4..5b863d04c 100644 --- a/include/randutils.h +++ b/include/randutils.h @@ -11,7 +11,7 @@ extern int rand_get_number(int low_n, int high_n); /* /dev/urandom based with fallback to rand() */ extern int random_get_fd(void); -extern void random_get_bytes(void *buf, size_t nbytes); +extern void ul_random_get_bytes(void *buf, size_t nbytes); extern const char *random_tell_source(void); #endif diff --git a/lib/randutils.c b/lib/randutils.c index 84c002187..bf8193338 100644 --- a/lib/randutils.c +++ b/lib/randutils.c @@ -102,7 +102,7 @@ int random_get_fd(void) #define UL_RAND_READ_ATTEMPTS 8 #define UL_RAND_READ_DELAY 125000 /* microseconds */ -void random_get_bytes(void *buf, size_t nbytes) +void ul_random_get_bytes(void *buf, size_t nbytes) { unsigned char *cp = (unsigned char *)buf; size_t i, n = nbytes; @@ -216,7 +216,7 @@ int main(int argc, char *argv[]) printf("Multiple random calls:\n"); for (i = 0; i < n; i++) { - random_get_bytes(&v, sizeof(v)); + ul_random_get_bytes(&v, sizeof(v)); printf("#%02zu: %25"PRIu64"\n", i, v); } @@ -227,7 +227,7 @@ int main(int argc, char *argv[]) if (!buf) err(EXIT_FAILURE, "failed to allocate buffer"); - random_get_bytes(buf, bufsz); + ul_random_get_bytes(buf, bufsz); for (i = 0; i < n; i++) { vp = (int64_t *) (buf + (i * sizeof(*vp))); printf("#%02zu: %25"PRIu64"\n", i, *vp); diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 890e33a26..82ccb6940 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -693,7 +693,7 @@ static int dos_create_disklabel(struct fdisk_context *cxt) /* random disk signature */ if (!has_id) { DBG(LABEL, ul_debug("DOS: generate new ID")); - random_get_bytes(&id, sizeof(id)); + ul_random_get_bytes(&id, sizeof(id)); } if (fdisk_has_protected_bootbits(cxt)) diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c index 69f9591a4..50039fc2e 100644 --- a/libuuid/src/gen_uuid.c +++ b/libuuid/src/gen_uuid.c @@ -275,7 +275,7 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low, } if ((last.tv_sec == 0) && (last.tv_usec == 0)) { - random_get_bytes(&clock_seq, sizeof(clock_seq)); + ul_random_get_bytes(&clock_seq, sizeof(clock_seq)); clock_seq &= 0x3FFF; gettimeofday(&last, NULL); last.tv_sec--; @@ -413,7 +413,7 @@ int __uuid_generate_time(uuid_t out, int *num) if (!has_init) { if (get_node_id(node_id) <= 0) { - random_get_bytes(node_id, 6); + ul_random_get_bytes(node_id, 6); /* * Set multicast bit, to prevent conflicts * with IEEE 802 addresses obtained from @@ -511,7 +511,7 @@ void __uuid_generate_random(uuid_t out, int *num) n = *num; for (i = 0; i < n; i++) { - random_get_bytes(buf, sizeof(buf)); + ul_random_get_bytes(buf, sizeof(buf)); uuid_unpack(buf, &uu); uu.clock_seq = (uu.clock_seq & 0x3FFF) | 0x8000; diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c index 549531454..315740127 100644 --- a/misc-utils/mcookie.c +++ b/misc-utils/mcookie.c @@ -184,7 +184,7 @@ int main(int argc, char **argv) randomness_from_files(&ctl); free(ctl.files); - random_get_bytes(&buf, RAND_BYTES); + ul_random_get_bytes(&buf, RAND_BYTES); ul_MD5Update(&ctl.ctx, buf, RAND_BYTES); if (ctl.verbose) fprintf(stderr, P_("Got %d byte from %s\n", diff --git a/sys-utils/ipcmk.c b/sys-utils/ipcmk.c index 5e942b775..0a84be77e 100644 --- a/sys-utils/ipcmk.c +++ b/sys-utils/ipcmk.c @@ -40,7 +40,7 @@ static int create_shm(size_t size, int permission) { key_t key; - random_get_bytes(&key, sizeof(key)); + ul_random_get_bytes(&key, sizeof(key)); return shmget(key, size, permission | IPC_CREAT); } @@ -48,7 +48,7 @@ static int create_msg(int permission) { key_t key; - random_get_bytes(&key, sizeof(key)); + ul_random_get_bytes(&key, sizeof(key)); return msgget(key, permission | IPC_CREAT); } @@ -56,7 +56,7 @@ static int create_sem(int nsems, int permission) { key_t key; - random_get_bytes(&key, sizeof(key)); + ul_random_get_bytes(&key, sizeof(key)); return semget(key, nsems, permission | IPC_CREAT); } -- 2.29.2