]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
Fix searching for ASes
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 14:19:30 +0000 (14:19 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 14:19:30 +0000 (14:19 +0000)
The name of the AS has not been converted to lowercase
before which causes that we didn't find all ASes.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/as.c
src/database.c

index 8721eff7770077247f7678c9e0da37b12a1683d6..8be229ad72596a4b41dc0daa0bf29d13f50c0f37 100644 (file)
--- a/src/as.c
+++ b/src/as.c
@@ -131,18 +131,9 @@ int loc_as_to_database_v0(struct loc_as* as, struct loc_stringpool* pool,
 }
 
 int loc_as_match_string(struct loc_as* as, const char* string) {
-       int r = 1;
-
-       char* name = strdup(as->name);
-
-       // Convert string to lowercase
-       for (char* p = name; *p; p++)
-               *p = tolower(*p);
-
        // Search if string is in name
-       if (strstr(as->name, string) != NULL)
-               r = 0;
+       if (strcasestr(as->name, string) != NULL)
+               return 1;
 
-       free(name);
-       return r;
+       return 0;
 }
index 2c8af0c1c64791e7e0f3b1e9ac2c739ad8288a73..fe5e6dc6e0ebcb86a56b5629dc982ff5bc879ff1 100644 (file)
@@ -621,7 +621,7 @@ LOC_EXPORT struct loc_as* loc_database_enumerator_next_as(struct loc_database_en
                        return NULL;
 
                r = loc_as_match_string(as, enumerator->string);
-               if (r == 0) {
+               if (r == 1) {
                        DEBUG(enumerator->ctx, "AS%d (%s) matches %s\n",
                                loc_as_get_number(as), loc_as_get_name(as), enumerator->string);