Fix BIO_OutputStream::write to return the correct length.

This was leaving bad OpenSSL error states lying around for later
innocent calls to trip over.

Also clean up some of the other error reporting/handling.

Bug: 9822466
Bug: 10344304

(cherry picked from commit 9fcf4ef542e3bc040bba8ed3b40874e2ba6f2d9a)

Change-Id: Ib446417dc8eaaad0f517340a8c9b012f25bb9b15
1 file changed