Closed bfabiszewski closed 2 years ago
Thank you so much. All the code looks good to me. :)
/And good catch that I did not check the return value of fopen
!
I think we might have reached a point where we maybe should consider refactoring all the macro stuff.
I noticed that the library fails on two niche GNU flavors: GNU/Hurd and GNU/kFreeBSD. This PR is proposed fix. I tested that it works on both systems. In case you want to handle this some other way, these are my observations.
Fixing GNU/Hurd just requires that it is treated as linux. It is detected by
__GNU__
macro. The only tricky point is that hurd definesBSD
macro in itssys/param.h
header. So I unset it. As it has glibc it finally usesgetrandom
function call.GNU/kFreeBSD uses BSD kernel but does not have
arc4random
like other BSD family members. It does not haveSYS_getrandom
system call either. It hasgetrandom
function but it is just unusable stub (linker spits: "warning: getrandom is not implemented and will always fail"). The only option left is/dev/urandom
but we have to skip linux-specific part. I skipped whole/dev/random
polling and entropy related stuff as this is basically what libsodium does for systems other than linux.BTW. Pragma
message
is treated as warning by clang and it breaks-Werror
builds. In my repo I wrapped it in a macro so that I can enable it only when I need to debug.Thanks for the library!