Skip to content

Commit

Permalink
Fix compilation problem related to getrandom() on non-glibc systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed May 16, 2019
1 parent b1298df commit d05bd95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Broker:
with glibc >= 2.25. Without this fix, no random numbers would be generated
for e.g. on broker client id generation, and so clients connecting expecting
this feature would be unable to connect.
- Fix compilation problem related to getrandom() on non-glibc systems.

Clients:
- Fix -L url parsing when `/topic` part is missing.
Expand Down
7 changes: 4 additions & 3 deletions lib/util_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ and the Eclipse Distribution License is available at
# include <sys/stat.h>
#endif

#if !defined(WITH_TLS) && defined(__linux__)
# if defined(__GLIBC__) && __GLIBC_PREREQ(2, 25)
#if !defined(WITH_TLS) && defined(__linux__) && defined(__GLIBC__)
# if __GLIBC_PREREQ(2, 25)
# include <sys/random.h>
# define HAVE_GETRANDOM 1
# endif
#endif

Expand Down Expand Up @@ -325,7 +326,7 @@ int util__random_bytes(void *bytes, int count)
if(RAND_bytes(bytes, count) == 1){
rc = MOSQ_ERR_SUCCESS;
}
#elif defined(__GLIBC__) && __GLIBC_PREREQ(2, 25)
#elif defined(HAVE_GETRANDOM)
if(getrandom(bytes, count, 0) == count){
rc = MOSQ_ERR_SUCCESS;
}
Expand Down

0 comments on commit d05bd95

Please sign in to comment.