diff options
Diffstat (limited to 'sbin/isakmpd/x509.c')
-rw-r--r-- | sbin/isakmpd/x509.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sbin/isakmpd/x509.c b/sbin/isakmpd/x509.c index 1b50045be14..a8f08aefe82 100644 --- a/sbin/isakmpd/x509.c +++ b/sbin/isakmpd/x509.c @@ -1,5 +1,5 @@ -/* $OpenBSD: x509.c,v 1.16 2000/01/26 15:24:52 niklas Exp $ */ -/* $EOM: x509.c,v 1.26 1999/10/10 22:48:37 angelos Exp $ */ +/* $OpenBSD: x509.c,v 1.17 2000/01/27 08:43:06 niklas Exp $ */ +/* $EOM: x509.c,v 1.27 2000/01/27 08:45:54 niklas Exp $ */ /* * Copyright (c) 1998, 1999 Niels Provos. All rights reserved. @@ -223,13 +223,15 @@ x509_hash (u_int8_t *id, size_t len) u_int16_t bucket = 0; /* XXX We might resize if we are crossing a certain threshold. */ - len &= ~2; - for (i = 0; i < len; i += 2) + for (i = 0; i < len & ~1; i += 2) { /* Doing it this way avoids alignment problems. */ - bucket ^= (id[i] + 1) * (id[i + 1] + 257); + bucket ^= (id[i] + 1) * (id[i + 1] + 257); } - + /* Hash in the last character of odd length IDs too. */ + if (i < len) + bucket ^= (id[i] + 1) * (id[i] + 257); + bucket &= bucket_mask; return bucket; |