Skip to content

Commit 3410c98

Browse files
flichtenheldcron2
authored andcommitted
manage: Change kill_by_addr to use better types for port/proto
Change-Id: I750a0b8107baa77fb14558d0c8e4ef8020d62efd Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com> Acked-by: Gert Doering <gert@greenie.muc.de> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1310
1 parent 3e63c01 commit 3410c98

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/openvpn/manage.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,14 +608,14 @@ man_kill(struct management *man, const char *victim)
608608
if (status)
609609
{
610610
const int port = atoi(p3);
611-
const int proto = (streq(p1, "tcp")) ? PROTO_TCP_SERVER
612-
: (streq(p1, "udp")) ? PROTO_UDP
613-
: PROTO_NONE;
611+
const uint8_t proto = (streq(p1, "tcp")) ? PROTO_TCP_SERVER
612+
: (streq(p1, "udp")) ? PROTO_UDP
613+
: PROTO_NONE;
614614

615-
if ((port > 0 && port < 65536) && (proto != PROTO_NONE))
615+
if ((port > 0 && port < UINT16_MAX) && (proto != PROTO_NONE))
616616
{
617617
n_killed = (*man->persist.callback.kill_by_addr)(man->persist.callback.arg,
618-
addr, port, proto);
618+
addr, (uint16_t)port, proto);
619619
if (n_killed > 0)
620620
{
621621
msg(M_CLIENT, "SUCCESS: %d client(s) at address %s:%s:%d killed", n_killed,

src/openvpn/manage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ struct management_callback
178178
void (*status)(void *arg, const int version, struct status_output *so);
179179
void (*show_net)(void *arg, const msglvl_t msglevel);
180180
int (*kill_by_cn)(void *arg, const char *common_name);
181-
int (*kill_by_addr)(void *arg, const in_addr_t addr, const int port, const int proto);
181+
int (*kill_by_addr)(void *arg, const in_addr_t addr, const uint16_t port, const uint8_t proto);
182182
void (*delete_event)(void *arg, event_t event);
183183
int (*n_clients)(void *arg);
184184
bool (*send_cc_message)(void *arg, const char *message, const char *parameter);

src/openvpn/multi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3937,7 +3937,7 @@ management_callback_kill_by_cn(void *arg, const char *del_cn)
39373937
}
39383938

39393939
static int
3940-
management_callback_kill_by_addr(void *arg, const in_addr_t addr, const int port, const int proto)
3940+
management_callback_kill_by_addr(void *arg, const in_addr_t addr, const uint16_t port, const uint8_t proto)
39413941
{
39423942
struct multi_context *m = (struct multi_context *)arg;
39433943
struct hash_iterator hi;

src/openvpn/socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct link_socket_info
8989
const char *ipchange_command;
9090
const struct plugin_list *plugins;
9191
bool remote_float;
92-
int proto; /* Protocol (PROTO_x defined below) */
92+
uint8_t proto; /* Protocol (PROTO_x defined below) */
9393
sa_family_t af; /* Address family like AF_INET, AF_INET6 or AF_UNSPEC*/
9494
bool bind_ipv6_only;
9595
int mtu_changed; /* Set to true when mtu value is changed */

0 commit comments

Comments
 (0)