4 ms·
> EFAULT buf is outside the accessible address space. I wonder how arc4random_buf(NULL, 42) behaves. Or what happens if you pass it a pointer to an invalid mem
by wereHamster 12y ago
> EFAULT buf is outside the accessible address space.
I wonder how arc4random_buf(NULL, 42) behaves. Or what happens if you pass it a pointer to an invalid memory location. Yeah, can't fail, right...
- acqq 12y agoOnce we commit ourselves to write some C code some kinds of failures are expected and the ones you point to are of that kind. The topic here are actually the ones not expected by a C programmer who wishes to use the API function. I don't want this discussion to digress to talking about some other languages even if we all know they exist and can avoid the kind of errors you describe. That's still off topic.
- acveilleux 12y agoSIGSEGV Not a "failure" of the libc call per se and it terminates the caller app which, frankly, is the only safe thing to do. The Linux equivalent, while it can fail could be wrapped in a libc version that emulates arc4random behaviour (provide random or kill the app really.)