Skip to content

Commit f7c7fb5

Browse files
committed
Refactor update_option to access push_update_options_found directly
1 parent 49efe09 commit f7c7fb5

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

src/openvpn/options.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5414,14 +5414,14 @@ void
54145414
update_option(struct context *c, struct options *options, char *p[], bool is_inline,
54155415
const char *file, int line, const int level, const msglvl_t msglevel,
54165416
const unsigned int permission_mask, unsigned int *option_types_found,
5417-
struct env_set *es, unsigned int *update_options_found)
5417+
struct env_set *es)
54185418
{
54195419
const bool pull_mode = BOOL_CAST(permission_mask & OPT_P_PULL_MODE);
54205420
ASSERT(MAX_PARMS >= 7);
54215421

54225422
if (streq(p[0], "route") && p[1] && !p[5])
54235423
{
5424-
if (!(*update_options_found & OPT_P_U_ROUTE))
5424+
if (!(options->push_update_options_found & OPT_P_U_ROUTE))
54255425
{
54265426
VERIFY_PERMISSION(OPT_P_ROUTE);
54275427
if (!check_route_option(options, p, msglevel, pull_mode))
@@ -5434,12 +5434,12 @@ update_option(struct context *c, struct options *options, char *p[], bool is_inl
54345434
es, &c->net_ctx);
54355435
RESET_OPTION_ROUTES(options->routes, routes);
54365436
}
5437-
*update_options_found |= OPT_P_U_ROUTE;
5437+
options->push_update_options_found |= OPT_P_U_ROUTE;
54385438
}
54395439
}
54405440
else if (streq(p[0], "route-ipv6") && p[1] && !p[4])
54415441
{
5442-
if (!(*update_options_found & OPT_P_U_ROUTE6))
5442+
if (!(options->push_update_options_found & OPT_P_U_ROUTE6))
54435443
{
54445444
VERIFY_PERMISSION(OPT_P_ROUTE);
54455445
if (!check_route6_option(options, p, msglevel, pull_mode))
@@ -5452,12 +5452,12 @@ update_option(struct context *c, struct options *options, char *p[], bool is_inl
54525452
ROUTE_OPTION_FLAGS(&c->options), es, &c->net_ctx);
54535453
RESET_OPTION_ROUTES(options->routes_ipv6, routes_ipv6);
54545454
}
5455-
*update_options_found |= OPT_P_U_ROUTE6;
5455+
options->push_update_options_found |= OPT_P_U_ROUTE6;
54565456
}
54575457
}
54585458
else if (streq(p[0], "redirect-gateway") || streq(p[0], "redirect-private"))
54595459
{
5460-
if (!(*update_options_found & OPT_P_U_REDIR_GATEWAY))
5460+
if (!(options->push_update_options_found & OPT_P_U_REDIR_GATEWAY))
54615461
{
54625462
VERIFY_PERMISSION(OPT_P_ROUTE);
54635463
if (options->routes)
@@ -5470,12 +5470,12 @@ update_option(struct context *c, struct options *options, char *p[], bool is_inl
54705470
}
54715471
env_set_del(es, "route_redirect_gateway_ipv4");
54725472
env_set_del(es, "route_redirect_gateway_ipv6");
5473-
*update_options_found |= OPT_P_U_REDIR_GATEWAY;
5473+
options->push_update_options_found |= OPT_P_U_REDIR_GATEWAY;
54745474
}
54755475
}
54765476
else if (streq(p[0], "dns") && p[1])
54775477
{
5478-
if (!(*update_options_found & OPT_P_U_DNS))
5478+
if (!(options->push_update_options_found & OPT_P_U_DNS))
54795479
{
54805480
VERIFY_PERMISSION(OPT_P_DHCPDNS);
54815481
if (!check_dns_option(options, p, msglevel, pull_mode))
@@ -5484,13 +5484,13 @@ update_option(struct context *c, struct options *options, char *p[], bool is_inl
54845484
}
54855485
gc_free(&options->dns_options.gc);
54865486
CLEAR(options->dns_options);
5487-
*update_options_found |= OPT_P_U_DNS;
5487+
options->push_update_options_found |= OPT_P_U_DNS;
54885488
}
54895489
}
54905490
#if defined(_WIN32) || defined(TARGET_ANDROID)
54915491
else if (streq(p[0], "dhcp-option") && p[1] && !p[3])
54925492
{
5493-
if (!(*update_options_found & OPT_P_U_DHCP))
5493+
if (!(options->push_update_options_found & OPT_P_U_DHCP))
54945494
{
54955495
struct tuntap_options *o = &options->tuntap_options;
54965496
VERIFY_PERMISSION(OPT_P_DHCPDNS);
@@ -5520,17 +5520,17 @@ update_option(struct context *c, struct options *options, char *p[], bool is_inl
55205520
o->http_proxy_port = 0;
55215521
o->http_proxy = NULL;
55225522
#endif
5523-
*update_options_found |= OPT_P_U_DHCP;
5523+
options->push_update_options_found |= OPT_P_U_DHCP;
55245524
}
55255525
}
55265526
#else /* if defined(_WIN32) || defined(TARGET_ANDROID) */
55275527
else if (streq(p[0], "dhcp-option") && p[1] && !p[3])
55285528
{
5529-
if (!(*update_options_found & OPT_P_U_DHCP))
5529+
if (!(options->push_update_options_found & OPT_P_U_DHCP))
55305530
{
55315531
VERIFY_PERMISSION(OPT_P_DHCPDNS);
55325532
delete_all_dhcp_fo(options, &es->list);
5533-
*update_options_found |= OPT_P_U_DHCP;
5533+
options->push_update_options_found |= OPT_P_U_DHCP;
55345534
}
55355535
}
55365536
#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */

src/openvpn/options.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,14 +865,11 @@ void remove_option(struct context *c, struct options *options, char *p[], bool i
865865
* @param option_types_found A pointer to the variable where the flags corresponding to the options
866866
* found are stored.
867867
* @param es The environment set structure.
868-
* @param update_options_found A pointer to the variable where the flags corresponding to the update
869-
* options found are stored, used to check if an option of the same type has already been processed
870-
* by update_option() within the same push-update message.
871868
*/
872869
void update_option(struct context *c, struct options *options, char *p[], bool is_inline,
873870
const char *file, int line, const int level, const msglvl_t msglevel,
874871
const unsigned int permission_mask, unsigned int *option_types_found,
875-
struct env_set *es, unsigned int *update_options_found);
872+
struct env_set *es);
876873

877874
void parse_argv(struct options *options, const int argc, char *argv[], const msglvl_t msglevel,
878875
const unsigned int permission_mask, unsigned int *option_types_found,

src/openvpn/options_parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ apply_push_options(struct context *c, struct options *options, struct buffer *bu
569569
* This prevents routes from being reset on each continuation message.
570570
*/
571571
update_option(c, options, p, false, file, line_num, 0, msglevel, permission_mask,
572-
option_types_found, es, &options->push_update_options_found);
572+
option_types_found, es);
573573
}
574574
}
575575
}

tests/unit_tests/openvpn/test_options_parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void
6060
update_option(struct context *c, struct options *options, char *p[], bool is_inline,
6161
const char *file, int line, const int level, const msglvl_t msglevel,
6262
const unsigned int permission_mask, unsigned int *option_types_found,
63-
struct env_set *es, unsigned int *update_options_found)
63+
struct env_set *es)
6464
{
6565
}
6666

0 commit comments

Comments
 (0)