crypto/openssl: fix extra bytes written at end of data