>From 93540f602ea0918c410d23f10b6a30ab7fd08aa9 Mon Sep 17 00:00:00 2001 From: Alexander Cherepanov Date: Mon, 13 May 2013 01:12:20 +0400 Subject: [PATCH] Get rid of strncmp with n==1. --- src/BFEgg_fmt_plug.c | 2 +- src/MSCHAPv2_bs_fmt_plug.c | 10 +++++----- src/MSCHAPv2_fmt_plug.c | 10 +++++----- src/NETLMv2_fmt_plug.c | 12 ++++++------ src/NETNTLMv2_fmt_plug.c | 12 ++++++------ src/opencl_ntlmv2_fmt.c | 12 ++++++------ 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/BFEgg_fmt_plug.c b/src/BFEgg_fmt_plug.c index 01c7fd6..22ab363 100644 --- a/src/BFEgg_fmt_plug.c +++ b/src/BFEgg_fmt_plug.c @@ -52,7 +52,7 @@ static char _atoi64[0x100]; static int valid(char *ciphertext, struct fmt_main *self) { char *pos; - if (strncmp(ciphertext, "+", 1) != 0) return 0; + if (*ciphertext != '+') return 0; if (strlen(ciphertext) != CIPHERTEXT_LENGTH) return 0; for (pos = &ciphertext[1]; atoi64[ARCH_INDEX(*pos)] != 0x7F; pos++); diff --git a/src/MSCHAPv2_bs_fmt_plug.c b/src/MSCHAPv2_bs_fmt_plug.c index 06f048e..fc3d66b 100644 --- a/src/MSCHAPv2_bs_fmt_plug.c +++ b/src/MSCHAPv2_bs_fmt_plug.c @@ -133,7 +133,7 @@ static int valid_long(char *ciphertext) /* Validate Authenticator/Server Challenge Length */ pos = &ciphertext[10]; - for (pos2 = pos; strncmp(pos2, "$", 1) != 0; pos2++) + for (pos2 = pos; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -142,7 +142,7 @@ static int valid_long(char *ciphertext) /* Validate MSCHAPv2 Response Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -151,7 +151,7 @@ static int valid_long(char *ciphertext) /* Validate Peer/Client Challenge Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -177,7 +177,7 @@ static int valid_short(char *ciphertext) /* Validate MSCHAPv2 Challenge Length */ pos = &ciphertext[10]; - for (pos2 = pos; strncmp(pos2, "$", 1) != 0; pos2++) + for (pos2 = pos; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -186,7 +186,7 @@ static int valid_short(char *ciphertext) /* Validate MSCHAPv2 Response Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; diff --git a/src/MSCHAPv2_fmt_plug.c b/src/MSCHAPv2_fmt_plug.c index 35c484d..633f5f4 100644 --- a/src/MSCHAPv2_fmt_plug.c +++ b/src/MSCHAPv2_fmt_plug.c @@ -191,7 +191,7 @@ static int valid_long(char *ciphertext) /* Validate Authenticator/Server Challenge Length */ pos = &ciphertext[10]; - for (pos2 = pos; strncmp(pos2, "$", 1) != 0; pos2++) + for (pos2 = pos; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -200,7 +200,7 @@ static int valid_long(char *ciphertext) /* Validate MSCHAPv2 Response Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -209,7 +209,7 @@ static int valid_long(char *ciphertext) /* Validate Peer/Client Challenge Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -235,7 +235,7 @@ static int valid_short(char *ciphertext) /* Validate MSCHAPv2 Challenge Length */ pos = &ciphertext[10]; - for (pos2 = pos; strncmp(pos2, "$", 1) != 0; pos2++) + for (pos2 = pos; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -244,7 +244,7 @@ static int valid_short(char *ciphertext) /* Validate MSCHAPv2 Response Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; diff --git a/src/NETLMv2_fmt_plug.c b/src/NETLMv2_fmt_plug.c index df6c097..d04139b 100644 --- a/src/NETLMv2_fmt_plug.c +++ b/src/NETLMv2_fmt_plug.c @@ -136,7 +136,7 @@ static int netlmv2_valid(char *ciphertext, struct fmt_main *self) pos = &ciphertext[9]; /* Validate Username and Domain Length */ - for (pos2 = pos; strncmp(pos2, "$", 1) != 0; pos2++) + for (pos2 = pos; *pos2 != '$'; pos2++) if ((unsigned char)*pos2 < 0x20) return 0; @@ -145,7 +145,7 @@ static int netlmv2_valid(char *ciphertext, struct fmt_main *self) /* Validate Server Challenge Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -154,7 +154,7 @@ static int netlmv2_valid(char *ciphertext, struct fmt_main *self) /* Validate LMv2 Response Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -223,7 +223,7 @@ static char *netlmv2_split(char *ciphertext, int index) int identity_length = 0; /* Calculate identity length */ - for (pos = ciphertext + 9; strncmp(pos, "$", 1) != 0; pos++); + for (pos = ciphertext + 9; *pos != '$'; pos++); identity_length = pos - (ciphertext + 9); memset(out, 0, TOTAL_LENGTH + 1); @@ -241,7 +241,7 @@ static void *netlmv2_get_binary(char *ciphertext) if (!binary) binary = mem_alloc_tiny(BINARY_SIZE, MEM_ALIGN_WORD); - for (pos = ciphertext + 9; strncmp(pos, "$", 1) != 0; pos++); + for (pos = ciphertext + 9; *pos != '$'; pos++); identity_length = pos - (ciphertext + 9); ciphertext += 9 + identity_length + 1 + CHALLENGE_LENGTH / 2 + 1; @@ -329,7 +329,7 @@ static void *netlmv2_get_salt(char *ciphertext) if (!binary_salt) binary_salt = mem_alloc_tiny(SALT_SIZE, MEM_ALIGN_WORD); /* Calculate identity length */ - for (pos = ciphertext + 9; strncmp(pos, "$", 1) != 0; pos++); + for (pos = ciphertext + 9; *pos != '$'; pos++); identity_length = pos - (ciphertext + 9); /* Convert identity (username + domain) string to NT unicode */ diff --git a/src/NETNTLMv2_fmt_plug.c b/src/NETNTLMv2_fmt_plug.c index d0183a5..8470754 100644 --- a/src/NETNTLMv2_fmt_plug.c +++ b/src/NETNTLMv2_fmt_plug.c @@ -146,7 +146,7 @@ static int netntlmv2_valid(char *ciphertext, struct fmt_main *self) pos = &ciphertext[11]; /* Validate Username and Domain Length */ - for (pos2 = pos; strncmp(pos2, "$", 1) != 0; pos2++) + for (pos2 = pos; *pos2 != '$'; pos2++) if ((unsigned char)*pos2 < 0x20) return 0; @@ -155,7 +155,7 @@ static int netntlmv2_valid(char *ciphertext, struct fmt_main *self) /* Validate Server Challenge Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -164,7 +164,7 @@ static int netntlmv2_valid(char *ciphertext, struct fmt_main *self) /* Validate NTLMv2 Response Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -232,7 +232,7 @@ static char *netntlmv2_split(char *ciphertext, int index) int identity_length = 0; /* Calculate identity length */ - for (pos = ciphertext + 11; strncmp(pos, "$", 1) != 0; pos++); + for (pos = ciphertext + 11; *pos != '$'; pos++); identity_length = pos - (ciphertext + 11); memset(out, 0, TOTAL_LENGTH + 1); @@ -250,7 +250,7 @@ static void *netntlmv2_get_binary(char *ciphertext) if (!binary) binary = mem_alloc_tiny(BINARY_SIZE, MEM_ALIGN_WORD); - for (pos = ciphertext + 11; strncmp(pos, "$", 1) != 0; pos++); + for (pos = ciphertext + 11; *pos != '$'; pos++); identity_length = pos - (ciphertext + 11); ciphertext += 11 + identity_length + 1 + SERVER_CHALL_LENGTH + 1; @@ -376,7 +376,7 @@ static void *netntlmv2_get_salt(char *ciphertext) if (!binary_salt) binary_salt = mem_alloc_tiny(SALT_SIZE_MAX, MEM_ALIGN_WORD); /* Calculate identity length */ - for (pos = ciphertext + 11; strncmp(pos, "$", 1) != 0; pos++); + for (pos = ciphertext + 11; *pos != '$'; pos++); /* Convert identity (username + domain) string to NT unicode */ #if !ARCH_ALLOWS_UNALIGNED diff --git a/src/opencl_ntlmv2_fmt.c b/src/opencl_ntlmv2_fmt.c index 0e9fbfd..854fcf8 100644 --- a/src/opencl_ntlmv2_fmt.c +++ b/src/opencl_ntlmv2_fmt.c @@ -167,7 +167,7 @@ static void *get_salt(char *ciphertext) memset(binary_salt, 0, SALT_SIZE_MAX); /* Calculate identity length */ - for (pos = ciphertext + 11; strncmp(pos, "$", 1) != 0; pos++); + for (pos = ciphertext + 11; *pos != '$'; pos++); /* Convert identity (username + domain) string to NT unicode */ identity_length = enc_to_utf16((UTF16*)binary_salt, 64, (unsigned char *)ciphertext + 11, pos - (ciphertext + 11)) * sizeof(UTF16); @@ -446,7 +446,7 @@ static int valid(char *ciphertext, struct fmt_main *self) pos = &ciphertext[11]; /* Validate Username and Domain Length */ - for (pos2 = pos; strncmp(pos2, "$", 1) != 0; pos2++) + for (pos2 = pos; *pos2 != '$'; pos2++) if ((unsigned char)*pos2 < 0x20) return 0; @@ -462,7 +462,7 @@ static int valid(char *ciphertext, struct fmt_main *self) /* Validate Server Challenge Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -471,7 +471,7 @@ static int valid(char *ciphertext, struct fmt_main *self) /* Validate NTLMv2 Response Length */ pos2++; pos = pos2; - for (; strncmp(pos2, "$", 1) != 0; pos2++) + for (; *pos2 != '$'; pos2++) if (atoi16[ARCH_INDEX(*pos2)] == 0x7F) return 0; @@ -552,7 +552,7 @@ static char *split(char *ciphertext, int index) int identity_length = 0; /* Calculate identity length */ - for (pos = ciphertext + 11; strncmp(pos, "$", 1) != 0; pos++); + for (pos = ciphertext + 11; *pos != '$'; pos++); identity_length = pos - (ciphertext + 11); memset(out, 0, sizeof(out)); @@ -570,7 +570,7 @@ static void *get_binary(char *ciphertext) if (!binary) binary = mem_alloc_tiny(DIGEST_SIZE, MEM_ALIGN_WORD); - for (pos = ciphertext + 11; strncmp(pos, "$", 1) != 0; pos++); + for (pos = ciphertext + 11; *pos != '$'; pos++); identity_length = pos - (ciphertext + 11); ciphertext += 11 + identity_length + 1 + SERVER_CHALL_LENGTH + 1; -- 1.7.2.5