MobileChromeApps / cordova-plugin-chrome-apps-sockets-tcp

BSD 3-Clause "New" or "Revised" License
44 stars 52 forks source link

Android: Fix writes being silently truncated when sending large ArrayBuffers #9

Open Stefano1964 opened 8 years ago

Stefano1964 commented 8 years ago

Hi, is this really fixed? I use this plugin in iOS and Android for an email client. While on iOS i've no problem, on Android when i send (via smtp) array larger then 20/30k i got no response from the email server. Edit: send is truncated after 16384 bytes

Stefano1964 commented 8 years ago

I think i've found the bug: In dequeueSend()

        do {
          res = sslEngine.wrap(sendPacket.data, sslNetBuffer);
        } while (maybeGrowBuffersForWrap(res));

in wrap if src it's bigger than dest in function maybeGrowBuffersForWrap(res) it's expected to have BUFFER_OVERFLOW as status in order to increase the buffer size, but there is a bug in Android 5.x where status is always OK: https://code.google.com/p/android/issues/detail?id=172187 it's for unwrap, but it's the same for wrap (i've tested and the result is always OK, also when the expected status is BUFFER_UNDERFLOW) This is because if src > 16kb the result is always cutted to 16kb

darkyen commented 8 years ago

@Stefano1964 any workaround ?