Re:Arc4random – randomization for all occasions
by acqq on Saturday November 22, 2014 @05:59AM
(#8645313)
Once 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.
Re:Arc4random – randomization for all occasions
by acveilleux on Saturday November 22, 2014 @10:33AM
(#8645725)
SIGSEGV
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.)
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...