diff libpurple/protocols/msn/directconn.c @ 28238:3157a8ea0012

Just add a note that this code sucks
author Mark Doliner <mark@kingant.net>
date Thu, 13 Aug 2009 01:47:54 +0000
parents 4f7eded28919
children 119bd7b072eb
line wrap: on
line diff
--- a/libpurple/protocols/msn/directconn.c	Thu Aug 13 01:31:15 2009 +0000
+++ b/libpurple/protocols/msn/directconn.c	Thu Aug 13 01:47:54 2009 +0000
@@ -259,6 +259,19 @@
 	directconn = data;
 
 	/* Let's read the length of the data. */
+#error This code is broken.  See the note below.
+	/*
+	 * TODO: This has problems!  First of all, sizeof(body_len) will be
+	 *       different on 32bit systems and on 64bit systems (4 bytes
+	 *       vs. 8 bytes).
+	 *       Secondly, we're reading from a TCP stream.  There is no
+	 *       guarantee that we have received the number of bytes we're
+	 *       trying to read.  We need to read into a buffer.  If read
+	 *       returns <0 then we need to check errno.  If errno is EAGAIN
+	 *       then don't destroy anything, just exit and wait for more
+	 *       data.  See every other function in libpurple that does this
+	 *       correctly for an example.
+	 */
 	len = read(directconn->fd, &body_len, sizeof(body_len));
 
 	if (len <= 0)