im.pidgin.pidgin: dbdb39b0de2b28e9a46681b14152bc0f25d96886

rlaager at pidgin.im rlaager at pidgin.im
Sun Jan 13 23:23:31 EST 2008


-----------------------------------------------------------------
Revision: dbdb39b0de2b28e9a46681b14152bc0f25d96886
Ancestor: 2a6a07744921317ab43ace2c71d306af571c60f6
Author: rlaager at pidgin.im
Date: 2008-01-13T21:20:19
Branch: im.pidgin.pidgin

Modified files:
        libpurple/ft.c

ChangeLog: 

Part of a large patch from o_sukhodolsky to fix some build warnings.
Refs #1344

-------------- next part --------------
============================================================
--- libpurple/ft.c	ba6fd83e4f984df254257d886e6c2b12291f2986
+++ libpurple/ft.c	1686a4e5385e2f194f4cc7f0d68082293b47a0dd
@@ -32,6 +32,7 @@
 #include "proxy.h"
 #include "request.h"
 #include "util.h"
+#include "debug.h"
 
 #define FT_INITIAL_BUFFER_SIZE 4096
 #define FT_MAX_BUFFER_SIZE     65535
@@ -903,7 +904,12 @@ transfer_cb(gpointer data, gint source, 
 	if (condition & PURPLE_INPUT_READ) {
 		r = purple_xfer_read(xfer, &buffer);
 		if (r > 0) {
-			fwrite(buffer, 1, r, xfer->dest_fp);
+			const size_t wc = fwrite(buffer, 1, r, xfer->dest_fp);
+			if (wc != r) {
+				purple_debug_error("filetransfer", "Unable to write whole buffer.\n");
+				purple_xfer_cancel_remote(xfer);
+				return;
+			}
 		} else if(r < 0) {
 			purple_xfer_cancel_remote(xfer);
 			return;
@@ -911,6 +917,7 @@ transfer_cb(gpointer data, gint source, 
 	}
 
 	if (condition & PURPLE_INPUT_WRITE) {
+		size_t result;
 		size_t s = MIN(purple_xfer_get_bytes_remaining(xfer), xfer->current_buffer_size);
 
 		/* this is so the prpl can keep the connection open
@@ -925,7 +932,13 @@ transfer_cb(gpointer data, gint source, 
 
 		buffer = g_malloc0(s);
 
-		fread(buffer, 1, s, xfer->dest_fp);
+		result = fread(buffer, 1, s, xfer->dest_fp);
+		if (result != s) {
+			purple_debug_error("filetransfer", "Unable to read whole buffer.\n");
+			purple_xfer_cancel_remote(xfer);
+			g_free(buffer);
+			return;
+		}
 
 		/* Write as much as we're allowed to. */
 		r = purple_xfer_write(xfer, buffer, s);


More information about the Commits mailing list