Add more errors checks

Check if open '/dev/urandom' failed.
Check also errors from 'malloc' and 'read'