adium/adium

I hope this is the proper fix to #16356: When any data has been read in the SocketRead for-loop, return noErr when we encounter an EOF. On the next call, it will return errSSLClosedGraceful.

This should fix an -9806 (errSSLClosedAbort) error in SIPE.

Fixes #16356
--- a/Plugins/Purple Service/libpurple_extensions/ssl-cdsa.c Mon May 26 13:04:27 2014 +0200
+++ b/Plugins/Purple Service/libpurple_extensions/ssl-cdsa.c Mon May 26 13:10:47 2014 +0200
@@ -231,7 +231,14 @@
bytesRead = 0;
rrtn = read(sock, currData, bytesToGo);
if (rrtn == 0) {
- rtn = errSSLClosedGraceful;
+ /* We got an EOF. However, when we have already read some bytes in a previous iteration of this loop,
+ * then we should return noErr to make sure CDSA processes all that data.
+ * When initLen is still equal to bytesToGo, we haven't read anything, so we can inform CDSA that we're
+ * closed.
+ */
+ if (initLen == bytesToGo) {
+ rtn = errSSLClosedGraceful;
+ }
break;
} else if (rrtn < 0) {
/* this is guesswork... */