diff --git a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c index 7a9512b6..9a0d32dd 100644 --- a/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +++ b/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c @@ -134,7 +134,13 @@ randombytes_salsa20_random_random_dev_open(void) do { fd = open(*device, O_RDONLY); if (fd != -1) { - if (fstat(fd, &st) == 0 && S_ISCHR(st.st_mode)) { + if (fstat(fd, &st) == 0 && +# ifdef S_IFNAM + (S_IFNAM(st.st_mode) || S_ISCHR(st.st_mode)) +# else + S_ISCHR(st.st_mode) +# endif + ) { # if defined(F_SETFD) && defined(FD_CLOEXEC) (void) fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); # endif diff --git a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c index d09c558f..a04a68f9 100644 --- a/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +++ b/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c @@ -119,7 +119,13 @@ randombytes_sysrandom_random_dev_open(void) do { fd = open(*device, O_RDONLY); if (fd != -1) { - if (fstat(fd, &st) == 0 && S_ISCHR(st.st_mode)) { + if (fstat(fd, &st) == 0 && +# ifdef S_IFNAM + (S_IFNAM(st.st_mode) || S_ISCHR(st.st_mode)) +# else + S_ISCHR(st.st_mode) +# endif + ) { # if defined(F_SETFD) && defined(FD_CLOEXEC) (void) fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); # endif