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

Sun, 13 Jan 2008 21:15:04 +0000

author
Richard Laager <rlaager@pidgin.im>
date
Sun, 13 Jan 2008 21:15:04 +0000
changeset 22193
134029596e99
parent 22192
caf56838b384
child 22194
3e48f2d3d083

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.

libpurple/protocols/qq/file_trans.c file | annotate | diff | comparison | revisions
--- 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)

mercurial