diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2009-12-08 21:10:25 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2009-12-08 21:10:25 +0000 |
commit | 71b4cf72a22130be661d966e74219afd11b9cae2 (patch) | |
tree | 41f40d61d445cab1c109f17422c14bc44090f050 /usr.sbin | |
parent | 3c9dad37612752049d78fc21aa191381eeaf61c9 (diff) |
Fix overflow bug found by Holger Mikolon, thanks.
committed slightly different fix.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/crunchgen/mangle.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/crunchgen/mangle.c b/usr.sbin/crunchgen/mangle.c index a9bb721853e..513bb65c99f 100644 --- a/usr.sbin/crunchgen/mangle.c +++ b/usr.sbin/crunchgen/mangle.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mangle.c,v 1.1 2009/12/04 04:59:48 drahn Exp $ */ +/* $OpenBSD: mangle.c,v 1.2 2009/12/08 21:10:24 drahn Exp $ */ /* * Copyright (c) 2009 Dale Rahn. * All rights reserved. @@ -130,10 +130,13 @@ mangle_str(char *str) int keyval; len = strlen(str); + if (len == 0) + return; /* nothing to mangle */ + if (len > MAX_KEY_STR_LEN) - len = MAX_KEY_STR_LEN-1; + len = MAX_KEY_STR_LEN; - keyval = key[len]++; + keyval = key[len-1]++; for (i = 0; i < len; i++) { int idx = keyval % NUM_KEYS; |