changeset 22072:ac48f2e34359

Part of a large patch from o_sukhodolsky to fix some build warnings. Refs #1344 I changed this somewhat. If someone cares about QQ, they should really fix the TODO I noted here.
author Richard Laager <rlaager@wiktel.com>
date Sun, 13 Jan 2008 21:15:04 +0000
parents 85cda171621a
children f90462eb434b
files libpurple/protocols/qq/file_trans.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/qq/file_trans.c	Sun Jan 13 21:04:47 2008 +0000
+++ b/libpurple/protocols/qq/file_trans.c	Sun Jan 13 21:15:04 2008 +0000
@@ -97,6 +97,7 @@
 	guint8 *buffer;
 	PurpleCipher *cipher;
 	PurpleCipherContext *context;
+	size_t wc;
 
 	const gint QQ_MAX_FILE_MD5_LENGTH = 10002432;
 
@@ -109,15 +110,20 @@
 
 	buffer = g_newa(guint8, filelen);
 	g_return_if_fail(buffer != NULL);
-	fread(buffer, filelen, 1, fp);
+	wc = fread(buffer, filelen, 1, fp);
+	fclose(fp);
+	if (wc != 1) {
+		purple_debug_error("qq", "Unable to read file: %s\n", filename);
+
+		/* TODO: XXX: Really, the caller should be modified to deal with this properly. */
+		return;
+	}
 
 	cipher = purple_ciphers_find_cipher("md5");
 	context = purple_cipher_context_new(cipher, NULL);
 	purple_cipher_context_append(context, buffer, filelen);
 	purple_cipher_context_digest(context, 16, md5, NULL);
 	purple_cipher_context_destroy(context);
-
-	fclose(fp);
 }
 
 static void _qq_get_file_header(guint8 *buf, guint8 **cursor, gint buflen, qq_file_header *fh)