diff libpurple/dnssrv.c @ 22107:bfe1854bbf87

More compiler warning fixes from o_sukhodolsky (with additions by me). Fixes #4643, references #1344.
author Mark Doliner <mark@kingant.net>
date Mon, 14 Jan 2008 07:13:49 +0000
parents 4604cad304cb
children df77b89a4025
line wrap: on
line diff
--- a/libpurple/dnssrv.c	Mon Jan 14 06:44:14 2008 +0000
+++ b/libpurple/dnssrv.c	Mon Jan 14 07:13:49 2008 +0000
@@ -200,12 +200,20 @@
 	PurpleSrvCallback cb = query_data->cb;
 	int status;
 
-	if (read(source, &size, sizeof(int)) > 0)
+	if (read(source, &size, sizeof(int)) == sizeof(int))
 	{
+		ssize_t red;
 		purple_debug_info("dnssrv","found %d SRV entries\n", size);
 		tmp = res = g_new0(PurpleSrvResponse, size);
 		for (i = 0; i < size; i++) {
-			read(source, tmp++, sizeof(PurpleSrvResponse));
+			red = read(source, tmp++, sizeof(PurpleSrvResponse));
+			if (red != sizeof(PurpleSrvResponse)) {
+				purple_debug_error("dnssrv","unable to read srv "
+						"response: %s\n", g_strerror(errno));
+				size = 0;
+				g_free(res);
+				res = NULL;
+			}
 		}
 	}
 	else