* Bug report - Solaris 11.3 conflicting types for 'random_get_bytes'
@ 2020-11-01 14:16 Sad Clouds
2020-11-02 22:26 ` [PATCH] lib/randutils: rename random_get_bytes() Sami Kerola
0 siblings, 1 reply; 3+ messages in thread
From: Sad Clouds @ 2020-11-01 14:16 UTC (permalink / raw)
To: util-linux
mcookie fails to build on Solaris 11.3 since it already has
random_get_bytes() function with a different signature. Please rename
it to something different.
===> Building for mcookie-2.32.1
/opt/pkg/bin/bmake all-recursive
Making all in po
CC lib/libcommon_la-randutils.lo
In file included from lib/randutils.c:29:
/usr/include/sys/random.h:71:12: error: conflicting types for 'random_get_bytes'
71 | extern int random_get_bytes(uint8_t *dbuf, size_t dlen);
| ^~~~~~~~~~~~~~~~
In file included from lib/randutils.c:19:
./include/randutils.h:14:13: note: previous declaration of 'random_get_bytes' was here
14 | extern void random_get_bytes(void *buf, size_t nbytes);
| ^~~~~~~~~~~~~~~~
*** [lib/libcommon_la-randutils.lo] Error code 1
bmake[2]: stopped in /opt/pkgbuild/objects/x11/mcookie/work/util-linux-2.32.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] lib/randutils: rename random_get_bytes()
2020-11-01 14:16 Bug report - Solaris 11.3 conflicting types for 'random_get_bytes' Sad Clouds
@ 2020-11-02 22:26 ` Sami Kerola
2020-11-03 11:39 ` Karel Zak
0 siblings, 1 reply; 3+ messages in thread
From: Sami Kerola @ 2020-11-02 22:26 UTC (permalink / raw)
To: cryintothebluesky; +Cc: util-linux, Sami Kerola
Rename random_get_bytes() to avoid colliding a Solaris library function that
has the same name.
Reported-by: Sad Clouds <cryintothebluesky@gmail.com>
Reference: https://lore.kernel.org/util-linux/20201101141608.ba365cf67d92ee3973226de9@gmail.com/
Reference: https://blogs.oracle.com/solaris/solaris-random-number-generation-v2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lib/randutils: rename random_get_bytes()
2020-11-02 22:26 ` [PATCH] lib/randutils: rename random_get_bytes() Sami Kerola
@ 2020-11-03 11:39 ` Karel Zak
0 siblings, 0 replies; 3+ messages in thread
From: Karel Zak @ 2020-11-03 11:39 UTC (permalink / raw)
To: Sami Kerola; +Cc: cryintothebluesky, util-linux
On Mon, Nov 02, 2020 at 10:26:18PM +0000, Sami Kerola wrote:
> 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(-)
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-03 11:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-01 14:16 Bug report - Solaris 11.3 conflicting types for 'random_get_bytes' Sad Clouds
2020-11-02 22:26 ` [PATCH] lib/randutils: rename random_get_bytes() Sami Kerola
2020-11-03 11:39 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).