Skip to content
Permalink
Browse files
Do not process <select/> nodes with no children
Signed-off-by: Julien Barbot <julien@barbot.org>
  • Loading branch information
klyr committed Apr 1, 2020
1 parent 24b759d commit 594c92ed50c26db1f94b7ea489040640a9eda7dc
Showing with 8 additions and 2 deletions.
  1. +8 −2 auth.c
10 auth.c
@@ -84,6 +84,14 @@ static int parse_auth_choice(struct openconnect_info *vpninfo, struct oc_auth_fo
xmlNode *opt_node;
int max_choices = 0, selection = 0;

for (opt_node = xml_node->children; opt_node; opt_node = opt_node->next)
max_choices++;

/* Return early when there is a <select/> tag with no children */
if (max_choices == 0) {
return 0;
}

opt = calloc(1, sizeof(*opt));
if (!opt)
return -ENOMEM;
@@ -98,8 +106,6 @@ static int parse_auth_choice(struct openconnect_info *vpninfo, struct oc_auth_fo
return -EINVAL;
}

for (opt_node = xml_node->children; opt_node; opt_node = opt_node->next)
max_choices++;

opt->choices = calloc(1, max_choices * sizeof(struct oc_choice *));
if (!opt->choices) {

0 comments on commit 594c92e

Please sign in to comment.