I don't think this patch is correct. wpend_tot keeps track of the user-provided buffer's original length, so that SSL_write(3) can detect when it's erroneously retried with a smaller buffer.