Skip to content

Commit

Permalink
ikev1: in quick mode, compare ip_protocol pointers directly
Browse files Browse the repository at this point in the history
do not dereference the pointers and compare the field .ipproto
  • Loading branch information
cagney authored and paulwouters committed Aug 8, 2023
1 parent 9e5a723 commit 23b712f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions programs/pluto/ikev1_quick.c
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,11 @@ static struct connection *fc_try(const struct connection *c,
const ip_selector *local_client,
const ip_selector *remote_client)
{
if (selector_is_unset(local_client) ||
selector_is_unset(remote_client)) {
return NULL;
}

struct connection *best = NULL;
policy_prio_t best_prio = BOTTOM_PRIO;
const bool remote_is_host = selector_eq_address(*remote_client,
Expand Down Expand Up @@ -2103,6 +2108,11 @@ static struct connection *fc_try_oppo(const struct connection *c,
const ip_selector *local_client,
const ip_selector *remote_client)
{
if (selector_is_unset(local_client) ||
selector_is_unset(remote_client)) {
return NULL;
}

struct connection *best = NULL;
policy_prio_t best_prio = BOTTOM_PRIO;

Expand Down Expand Up @@ -2224,6 +2234,16 @@ struct connection *find_v1_client_connection(struct connection *const c,
str_selectors(local_client, remote_client, &sb));
}

if (selector_is_unset(local_client)) {
dbg("peer's local client is not set");
return NULL;
}

if (selector_is_unset(remote_client)) {
dbg("peer's remote client is not set");
return NULL;
}

/*
* Give priority to current connection
* but even greater priority to a routed concrete connection.
Expand Down

0 comments on commit 23b712f

Please sign in to comment.