On 27/04/14 10:35, John Hughes wrote:
But that's the wrong place to fix it. The bug is realy in
$socket->syswrite, aka Crypt::SSLeay::Conn::write.
That's where the bug should be fixed.
This patch fixes it for me.
--- SSLeay.xs.dist 2007-08-13 19:42:33.000000000 +0200
+++ SSLeay.xs 2014-04-27 13:43:47.000000000 +0200
@@ -283,20 +283,40 @@
int len;
int offset = 0;
int n;
+ U8* tmpbuf = NULL;
INPUT:
char* buf = SvPV(ST(1), blen);
CODE:
+
+ if (DO_UTF8(ST(1))) {
+ STRLEN tmplen = blen;
+ bool is_utf8 = TRUE;
+ U8 * const result = bytes_from_utf8((const U8*) buf, &tmplen, &is_utf8);
+ if (is_utf8)
+ croak("Wide character in SSL write (bytes required)");
+
+ if (result != (U8*)buf) {
+ tmpbuf = result;
+ buf = (char*) tmpbuf;
+ blen = tmplen;
+ }
+ }
+
if (items > 2) {
len = SvOK(ST(2)) ? SvIV(ST(2)) : blen;
if (items > 3) {
offset = SvIV(ST(3));
if (offset < 0) {
- if (-offset > blen)
+ if (-offset > blen) {
+ Safefree(tmpbuf);
croak("Offset outside string");
+ }
offset += blen;
}
- else if (offset >= blen && blen > 0)
+ else if (offset >= blen && blen > 0) {
+ Safefree(tmpbuf);
croak("Offset outside string");
+ }
}
if (len > blen - offset)
len = blen - offset;
@@ -311,6 +331,7 @@
else {
RETVAL = &PL_sv_undef;
}
+ Safefree(tmpbuf);
OUTPUT:
RETVAL