libpurple/protocols/gg/lib/sha1.c

branch
release-2.x.y
changeset 37180
cf498d4b54bb
parent 35685
703d7d7bdf60
child 37181
06b74c255e95
--- a/libpurple/protocols/gg/lib/sha1.c	Fri Apr 10 13:27:57 2015 +0530
+++ b/libpurple/protocols/gg/lib/sha1.c	Sat May 09 14:54:05 2015 +0200
@@ -153,7 +153,11 @@
     state[3] += d;
     state[4] += e;
     /* Wipe variables */
-    a = b = c = d = e = 0;
+    memset(&a, 0, sizeof(a));
+    memset(&b, 0, sizeof(b));
+    memset(&c, 0, sizeof(c));
+    memset(&d, 0, sizeof(d));
+    memset(&e, 0, sizeof(e));
 }
 
 
@@ -201,7 +205,7 @@
 
 static int SHA1_Final(unsigned char digest[20], SHA_CTX* context)
 {
-uint32_t i, j;
+uint32_t i;
 unsigned char finalcount[8];
 
     for (i = 0; i < 8; i++) {
@@ -218,7 +222,6 @@
          ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
     }
     /* Wipe variables */
-    i = j = 0;
     memset(context->buffer, 0, 64);
     memset(context->state, 0, 20);
     memset(context->count, 0, 8);
@@ -302,6 +305,9 @@
 		if (res == -1 && errno != EINTR)
 			break;
 
+		if (res == 0)
+			break;
+
 		if (res != -1) {
 			if (!SHA1_Update(ctx, buf, res)) {
 				res = -1;

mercurial