diff options
author | Robey Pointer <robey@lag.net> | 2004-11-22 07:04:31 +0000 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2004-11-22 07:04:31 +0000 |
commit | 961525f3d8381b9cfc717f01c5c44cec83649106 (patch) | |
tree | 28f14f00c4167ed289079e8c831df4d6d5f1f072 /paramiko/primes.py | |
parent | fda92c6f4475494898aeb9f88972ce538b9ddb02 (diff) | |
download | paramiko-961525f3d8381b9cfc717f01c5c44cec83649106.tar.gz |
[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-111]
fix extremely unlikely channel counter wrapping
Transport's channel counter can overflow after 4 billion some channels are
created. make it wrap back around after 16 million instead. also allow the
logging channel to be set manually. fix some comments elsewhere.
Diffstat (limited to 'paramiko/primes.py')
-rw-r--r-- | paramiko/primes.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/paramiko/primes.py b/paramiko/primes.py index 8c7e0a61..f3809950 100644 --- a/paramiko/primes.py +++ b/paramiko/primes.py @@ -29,7 +29,7 @@ import util def _generate_prime(bits, randpool): "primtive attempt at prime generation" hbyte_mask = pow(2, bits % 8) - 1 - while 1: + while True: # loop catches the case where we increment n into a higher bit-range x = randpool.get_bytes((bits+7) // 8) if hbyte_mask > 0: @@ -54,7 +54,7 @@ def _roll_random(randpool, n): # power of 2), we have slightly better than 50% odds of getting one that # fits, so i can't guarantee that this loop will ever finish, but the odds # of it looping forever should be infinitesimal. - while 1: + while True: x = randpool.get_bytes(bytes) if hbyte_mask > 0: x = chr(ord(x[0]) & hbyte_mask) + x[1:] |