summaryrefslogtreecommitdiff
path: root/usr.bin/encrypt
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2014-12-29 17:07:18 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2014-12-29 17:07:18 +0000
commitea268afb47754539e6e860e918ffd12b6788c608 (patch)
treea03bf56e4b48aeb64969d684a6bcfe65e6bb3ad4 /usr.bin/encrypt
parent5be1016fbe863e793a2194d76a05a725f021b93c (diff)
impose some limits on the ideal rounds so nothing too crazy happens when
the clock results are weird
Diffstat (limited to 'usr.bin/encrypt')
-rw-r--r--usr.bin/encrypt/encrypt.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/encrypt/encrypt.c b/usr.bin/encrypt/encrypt.c
index 0f302b5706b..074fcec94cb 100644
--- a/usr.bin/encrypt/encrypt.c
+++ b/usr.bin/encrypt/encrypt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: encrypt.c,v 1.34 2014/12/24 22:04:26 tedu Exp $ */
+/* $OpenBSD: encrypt.c,v 1.35 2014/12/29 17:07:17 tedu Exp $ */
/*
* Copyright (c) 1996, Jason Downs. All rights reserved.
@@ -80,12 +80,12 @@ ideal_rounds(void)
duration = after - before;
/* too quick? slow it down. */
- while (duration <= CLOCKS_PER_SEC / 4) {
+ while (r < 16 && duration <= CLOCKS_PER_SEC / 4) {
r += 1;
duration *= 2;
}
/* too slow? speed it up. */
- while (duration > CLOCKS_PER_SEC / 2) {
+ while (r > 4 && duration > CLOCKS_PER_SEC / 2) {
r -= 1;
duration /= 2;
}