libpurple/ciphers/descipher.c

branch
soc.2013.gobjectification
changeset 34603
292fcbdaf528
parent 34215
717a428718a6
parent 34566
e0f887dee077
child 34619
b8d8c1516d74
--- a/libpurple/ciphers/descipher.c	Sat Jun 22 03:16:33 2013 +0530
+++ b/libpurple/ciphers/descipher.c	Sat Jun 22 14:19:45 2013 +0530
@@ -433,6 +433,8 @@
 	guint8 buf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
 	ssize_t out_len;
 
+	g_return_val_if_fail(out_size >= in_len, -1);
+
 	while(offset + 8 <= in_len) {
 		purple_des_cipher_ecb_crypt(des_cipher, input + offset, output + offset, 0);
 		offset += 8;
@@ -442,6 +444,7 @@
 
 	if(offset<in_len) {
 		out_len += in_len - offset;
+		g_return_val_if_fail(out_size >= out_len, -1);
 		tmp = offset;
 		while(tmp<in_len) {
 			buf[i++] = input[tmp];
@@ -463,6 +466,8 @@
 	guint8 buf[8] = {0,0,0,0,0,0,0,0};
 	ssize_t out_len;
 
+	g_return_val_if_fail(out_size >= in_len, -1);
+
 	while(offset + 8 <= in_len) {
 		purple_des_cipher_ecb_crypt(des_cipher, input + offset, output + offset, 1);
 		offset += 8;
@@ -471,6 +476,7 @@
 	out_len = in_len;
 	if(offset<in_len) {
 		out_len += in_len - offset;
+		g_return_val_if_fail(out_size >= out_len, -1);
 		tmp = offset;
 		while(tmp<in_len) {
 			buf[i++] = input[tmp];

mercurial