Mercurial > pidgin.yaz
changeset 22073:f90462eb434b
Part of a large patch from o_sukhodolsky to fix some build warnings.
Refs #1344
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 13 Jan 2008 21:20:19 +0000 |
parents | ac48f2e34359 |
children | 50b20401ce45 |
files | libpurple/ft.c |
diffstat | 1 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/ft.c Sun Jan 13 21:15:04 2008 +0000 +++ b/libpurple/ft.c Sun Jan 13 21:20:19 2008 +0000 @@ -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 @@ 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 @@ } 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 @@ 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);