diff --git a/src/modules/_Crypto/lib/rc4.c b/src/modules/_Crypto/lib/rc4.c
index a15fa8b84fa6cf42d3b325820b41775cbc2df6eb..14f3868a179bdc5a21a79facebfb9120016a8c0a 100644
--- a/src/modules/_Crypto/lib/rc4.c
+++ b/src/modules/_Crypto/lib/rc4.c
@@ -6,19 +6,20 @@
 #include <rc4.h>
 
 #ifdef RCSID
-RCSID("$Id: rc4.c,v 1.5 1997/03/15 04:52:44 nisse Exp $");
+RCSID("$Id: rc4.c,v 1.6 1997/04/18 20:08:59 nisse Exp $");
 #endif
 
 #define SWAP(a,b) do { int _t = a; a = b; b = _t; } while(0)
 
 void rc4_set_key(struct rc4_ctx *ctx, const unsigned INT8 *key, INT32 len)
 {
-  register unsigned INT8 i, j; /* Depends on the eight-bitness of these variables. */
+  register unsigned INT8 j; /* Depends on the eight-bitness of these variables. */
+  unsigned i;
   INT32 k;
 
   /* Initialize context */
   i = 0;
-  do ctx->S[i] = i; while (++i);
+  do ctx->S[i] = i; while (++i < 256);
 
   /* Expand key */
   i = j = k = 0;
@@ -26,7 +27,7 @@ void rc4_set_key(struct rc4_ctx *ctx, const unsigned INT8 *key, INT32 len)
     j += ctx->S[i] + key[k];
     SWAP(ctx->S[i], ctx->S[j]);
     k = (k+1) % len; /* Repeat key if needed */
-  } while(++i);
+  } while(++i < 256);
   
   ctx->i = ctx->j = 0;
 }