aboutsummaryrefslogtreecommitdiffstats
path: root/Source/lib/utils/identification.c
diff options
context:
space:
mode:
Diffstat (limited to 'Source/lib/utils/identification.c')
-rw-r--r--Source/lib/utils/identification.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/Source/lib/utils/identification.c b/Source/lib/utils/identification.c
index d99d0e453..33f3d92cd 100644
--- a/Source/lib/utils/identification.c
+++ b/Source/lib/utils/identification.c
@@ -808,6 +808,19 @@ static char *get_string(private_identification_t *this)
}
/**
+ * Implementation of identification_t.contains_wildcards.
+ */
+static bool contains_wildcards(private_identification_t *this)
+{
+ if (this->type == ID_ANY ||
+ memchr(this->encoded.ptr, '*', this->encoded.len) != NULL)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
* Default implementation of identification_t.equals and identification_t.belongs_to.
* compares encoded chunk for equality.
*/
@@ -840,6 +853,11 @@ static bool belongs_to_wc_string(private_identification_t *this, private_identif
{
char *this_str, *other_str, *pos;
+ if (other->type == ID_ANY)
+ {
+ return TRUE;
+ }
+
if (this->type == other->type)
{
/* try a binary comparison first */
@@ -875,11 +893,15 @@ static bool belongs_to_wc_string(private_identification_t *this, private_identif
/**
* Special implementation of identification_t.belongs_to for ID_ANY.
- * ANY matches any, even ANY, thats why its there...
+ * ANY matches only another ANY, but nothing other
*/
static bool belongs_to_any(private_identification_t *this, private_identification_t *other)
-{
- return TRUE;
+{
+ if (other->type == ID_ANY)
+ {
+ return TRUE;
+ }
+ return FALSE;
}
/**
@@ -890,6 +912,11 @@ static bool belongs_to_dn(private_identification_t *this, private_identification
{
int wildcards;
+ if (other->type == ID_ANY)
+ {
+ return TRUE;
+ }
+
if (this->type == other->type)
{
return match_dn(this->encoded, other->encoded, &wildcards);
@@ -932,6 +959,7 @@ static private_identification_t *identification_create()
this->public.get_encoding = (chunk_t (*) (identification_t*))get_encoding;
this->public.get_type = (id_type_t (*) (identification_t*))get_type;
this->public.get_string = (char* (*) (identification_t*))get_string;
+ this->public.contains_wildcards = (bool (*) (identification_t *this))contains_wildcards;
this->public.clone = (identification_t* (*) (identification_t*))clone;
this->public.destroy = (void (*) (identification_t*))destroy;
/* we use these as defaults, the may be overloaded for special ID types */