Opened 13 months ago

Last modified 8 weeks ago

#16356 new defect

SSL SocketRead should retry on noErr

Reported by: hpk104 Owned by:
Milestone: Adium 1.5.7 Component: Adium Core
Version: 1.5.4 Severity: normal
Keywords: Cc:
Patch Status:



Sometimes calls to SocketRead return 0 bytes but with errno = 0. Those cases should be handled identically to EAGAIN but instead return a fatal error. This is causing issues with the SIPE plugin connecting to Office365 accounts (and possibly in other plugins?)

Steps to reproduce

With the SIPE plugin the only step needed to reproduce is to configure an Office365 account.

Expected results

Successful connection to server.

Actual results

Connection fails with:

(Libpurple: cdsa) receive failed (-9802): Undefined error: 0


Able to reproduce with Adium 1.5.x on OS 10.8.x; have not tried on earlier Adium or OSX builds.


Identical account configuration and plugin version work under Pidgin on Windows, Linux and Mac. Increasing the receive buffer (to minimize calls to read) also serves as a workaround but is not a true fix.

Change History (7)

comment:1 Changed 13 months ago by sphynx

This seems to make sense (I'm not very familiar with this code myself).

SocketRead checks if the result of read is <= 0, and handles errno == 0 and rrtn == 0 as a errSSLFatalAlert, while that seems to indicate "no data available right now" (why doesn't it set EAGAIN, though?).

comment:2 Changed 13 months ago by Thijs Alkemade <me@…>

  • Resolution set to fixed
  • Status changed from new to closed

(In ef796c40efb0) Fix a read returning 0 in the SocketRead callback for SSL being handled as an error, while it's meant to indicate "no data available".

This would cause disconnections with the error "(Libpurple: cdsa) receive failed (-9802): Undefined error: 0".

Fixes #16356, fixes #15405, fixes #15411, fixes #15741

comment:3 Changed 10 months ago by sbuxhofer


I've opened a new ticket for the sipe client #16402, since it is failing to sign into lync 2010 office 365 accounts using corporate adfs tls auth.

Let me know if you need additional logs or debugs from adium. I;ve attached debugs on the sipe ticket in sourceforge.


comment:4 Changed 8 weeks ago by Thijs Alkemade <me@…>

(In f8d2f42c499b) Backed out ef796c40efb0: the code can cause busy loops on disconnect, especially with XMPP servers (in particular when prompted to enter a password).

Reverting this change until we have found the exact cause.

Refs #16356, fixes #16431

comment:5 Changed 8 weeks ago by sphynx

  • Resolution fixed deleted
  • Status changed from closed to new

comment:6 Changed 8 weeks ago by sphynx

I'm having another look at this and I think the original request was wrong. man 2 read says:

If successful, the number of bytes actually read is returned. Upon reading end-of-file, zero is returned. Otherwise, a -1 is returned and the global variable errno is set to indicate the error.

Therefore, reading 0 bytes must imply the socket is closed, no matter if errno is 0 or EAGAIN. It's true that the code doesn't handle that properly, but the right thing to do when reading 0 bytes is to close the socket.

comment:7 Changed 8 weeks ago by Thijs Alkemade <me@…>

(In 9b4717820ead) We should not read errno when reading 0 bytes, because it is not set. The connection has been closed.

Refs #16356

Note: See TracTickets for help on using tickets.