Nmap Development mailing list archives
[PATCH] Return earlier in optcmp() when strings don't "match"
From: Kris Katterjohn <kjak () ispwest com>
Date: Wed, 13 Sep 2006 19:41:08 -0500
The attached patch makes optcmp() return earlier when the string lengths don't match. Instead of going through the whole loop and then testing to see if we haven't hit the NULL byte, this tests the lengths before the loop. It's a diff against 4.20ALPHA6 (but applies cleanly to ALPHA7) Thanks, Kris Katterjohn
--- x/utils.cc 2006-08-28 22:26:10.000000000 -0500
+++ y/utils.cc 2006-09-12 16:16:16.000000000 -0500
@@ -213,6 +213,9 @@ char *chomp(char *string) {
two values are considered equivalant (for example, - and _ are
considered to be the same), nonzero otherwise. */
int optcmp(const char *a, const char *b) {
+ if (strlen(a) != strlen(b))
+ return 1;
+
while(*a && *b) {
if (*a == '_' || *a == '-') {
if (*b != '_' && *b != '-')
@@ -222,8 +225,6 @@ int optcmp(const char *a, const char *b)
return 1;
a++; b++;
}
- if (*a || *b)
- return 1;
return 0;
}
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- [PATCH] Return earlier in optcmp() when strings don't "match" Kris Katterjohn (Sep 13)
