From: Ted Lemon Date: Mon, 12 Apr 1999 21:33:34 +0000 (+0000) Subject: Cast unsigned chars to chars before passing to strlen. X-Git-Tag: V3-ALPHA-19990412~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34bef96b1915f6df33993ca549744d6261782c8d;p=thirdparty%2Fdhcp.git Cast unsigned chars to chars before passing to strlen. --- diff --git a/common/hash.c b/common/hash.c index 8fa51e69d..e8757fe92 100644 --- a/common/hash.c +++ b/common/hash.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: hash.c,v 1.13 1999/04/05 19:02:42 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; +"$Id: hash.c,v 1.14 1999/04/12 21:33:34 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -47,23 +47,12 @@ static INLINE int do_hash (name, len, size) register int accum = 0; register unsigned char *s = (unsigned char *)name; int i = len; - if (i) { - while (i--) { - /* Add the character in... */ - accum += *s++; - /* Add carry back in... */ - while (accum > 255) { - accum = (accum & 255) + (accum >> 8); - } - } - } else { - while (*s) { - /* Add the character in... */ - accum += *s++; - /* Add carry back in... */ - while (accum > 255) { - accum = (accum & 255) + (accum >> 8); - } + while (i--) { + /* Add the character in... */ + accum += *s++; + /* Add carry back in... */ + while (accum > 255) { + accum = (accum & 255) + (accum >> 8); } } return accum % size; @@ -82,7 +71,7 @@ void add_hash (table, name, len, pointer) return; if (!len) - len = strlen (name); + len = strlen ((char *)name); hashno = do_hash (name, len, table -> hash_count); bp = new_hash_bucket ("add_hash"); @@ -110,7 +99,7 @@ void delete_hash_entry (table, name, len) return; if (!len) - len = strlen (name); + len = strlen ((char *)name); hashno = do_hash (name, len, table -> hash_count); @@ -144,7 +133,7 @@ unsigned char *hash_lookup (table, name, len) if (!table) return (unsigned char *)0; if (!len) - len = strlen (name); + len = strlen ((char *)name); hashno = do_hash (name, len, table -> hash_count);