libressl / openbsd

Source code pulled from OpenBSD for LibreSSL - this includes most of the library and supporting code. The place to contribute to this code is via the OpenBSD CVS tree. Please mail patches to tech@openbsd.org, instead of submitting pull requests, since this tree is often rebased.
231 stars 92 forks source link

arc4random_buf() segfaults on MIPS32 with uClibc-0.9.33.2. #78

Closed nihilus closed 7 years ago

nihilus commented 7 years ago

arc4random_buf() segfaults on MIPS32 with uClibc-0.9.33.2 and Linux.

4a6f656c commented 7 years ago

Unfortunately we'll need more than this to investigate/resolve - can you please provide sample code and a back trace?

nihilus commented 7 years ago

@4a6f656c Yeah, it might be due to a buggy pthreads implementation or whatever; however porting the arc4random_buf() function to uClibc resolves this problem.

I guess other people might find this useful.

in libc/stdlib/arc4random.c I've added this:

void arc4random_buf(void *buf_, size_t n)
{
    unsigned char *buf = buf_;
    if (!rs_initialized)
        __arc4random_stir();
    while (n--) {
        buf[n] = arc4_getbyte(&rs);
    }
}
4a6f656c commented 7 years ago

@nihilus - thanks, if we can get a trace we might be able to isolate the problem, without that there's not much we can do. Since you have a workaround, I'll close this - please reopen if further information can be provided.