From bb343f9ba241bfc564e9f2b1f0950b685ac424bb Mon Sep 17 00:00:00 2001 From: Beyley Thomas Date: Fri, 25 Feb 2022 22:39:03 -0800 Subject: [PATCH] Allow binding to ports <1024 on non-linux builds (#136) * Allow binding to ports <1024 on non-linux builds This seems to be only a restriction on Linux and Mac versions older then Mojave * Fix port check on djui_panel_join_ip_parse_port --- src/pc/djui/djui_panel_host.c | 4 ++++ src/pc/djui/djui_panel_join.c | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pc/djui/djui_panel_host.c b/src/pc/djui/djui_panel_host.c index 582427c3..f49987d3 100644 --- a/src/pc/djui/djui_panel_host.c +++ b/src/pc/djui/djui_panel_host.c @@ -27,7 +27,11 @@ static bool djui_panel_host_port_valid(void) { port += (*buffer - '0'); buffer++; } +#if __linux__ return port >= 1024 && port <= 65535; +#else + return port <= 65535; +#endif } static void djui_panel_host_port_text_change(struct DjuiBase* caller) { diff --git a/src/pc/djui/djui_panel_join.c b/src/pc/djui/djui_panel_join.c index a5cb5752..c15d7ac8 100644 --- a/src/pc/djui/djui_panel_join.c +++ b/src/pc/djui/djui_panel_join.c @@ -52,13 +52,13 @@ static bool djui_panel_join_ip_parse_spacer(char** msg) { } static bool djui_panel_join_ip_parse_port(char** msg) { - int num = 0; + int port = 0; for (int i = 0; i < 5; i++) { char c = **msg; if (c >= '0' && c <= '9') { // is number - num *= 10; - num += (c - '0'); + port *= 10; + port += (c - '0'); *msg = *msg + 1; } else if (i == 0) { return false; @@ -67,7 +67,7 @@ static bool djui_panel_join_ip_parse_port(char** msg) { } } - return num >= 1024 && num <= 65535; + return port <= 65535; } static bool djui_panel_join_ip_valid(char* buffer) {