mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-10-14 09:55:33 +08:00
fix mem access problem reported by sanitizer
This commit is contained in:
@@ -1127,8 +1127,8 @@ void print_binary_chars(const char *a, int len) {
|
||||
u32_t djb2(unsigned char *str, int len) {
|
||||
u32_t hash = 5381;
|
||||
int c;
|
||||
int i = 0;
|
||||
while (c = *str++, i++ != len) {
|
||||
for (int i=0; i<len ;i++) {
|
||||
c = *(str++);
|
||||
hash = ((hash << 5) + hash) ^ c; /* (hash * 33) ^ c */
|
||||
}
|
||||
|
||||
@@ -1139,8 +1139,8 @@ u32_t djb2(unsigned char *str, int len) {
|
||||
u32_t sdbm(unsigned char *str, int len) {
|
||||
u32_t hash = 0;
|
||||
int c;
|
||||
int i = 0;
|
||||
while (c = *str++, i++ != len) {
|
||||
for (int i=0; i<len ;i++) {
|
||||
c = *(str++);
|
||||
hash = c + (hash << 6) + (hash << 16) - hash;
|
||||
}
|
||||
// hash=htonl(hash);
|
||||
|
Reference in New Issue
Block a user