[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r10202: Fix dumb bug introduced in r10199 (in tor/trunk: . src/common)



Author: nickm
Date: 2007-05-16 21:52:26 -0400 (Wed, 16 May 2007)
New Revision: 10202

Modified:
   tor/trunk/
   tor/trunk/src/common/crypto.c
Log:
 r12777@catbus:  nickm | 2007-05-16 21:52:23 -0400
 Fix dumb bug introduced in r10199



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r12777] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/common/crypto.c
===================================================================
--- tor/trunk/src/common/crypto.c	2007-05-16 22:16:13 UTC (rev 10201)
+++ tor/trunk/src/common/crypto.c	2007-05-17 01:52:26 UTC (rev 10202)
@@ -1494,12 +1494,14 @@
   tor_assert(key_out_len <= DIGEST_LEN*256);
 
   memcpy(tmp, key_in, key_in_len);
-  for (cp = key_out, i=0; key_out_len >= DIGEST_LEN;
+  for (cp = key_out, i=0; key_out_len;
        ++i, cp += DIGEST_LEN, key_out_len -= DIGEST_LEN) {
     tmp[key_in_len] = i;
     if (crypto_digest(digest, tmp, key_in_len+1))
       goto err;
     memcpy(cp, digest, MIN(DIGEST_LEN, key_out_len));
+    if (key_out_len < DIGEST_LEN)
+      break;
   }
   memset(tmp, 0, key_in_len+1);
   tor_free(tmp);