diff --git a/app/modules/wifi.c b/app/modules/wifi.c index 1a1e73d7..2970ef9a 100644 --- a/app/modules/wifi.c +++ b/app/modules/wifi.c @@ -1191,24 +1191,21 @@ static int wifi_sta_gethostname( lua_State* L ) } // Used by wifi_sta_sethostname_lua and wifi_change_default_hostname -static bool wifi_sta_sethostname(const char *hostname, size_t len) +// This function checks host name to ensure that it follows RFC 952 & RFC 1123 host name standards. +static bool wifi_sta_checkhostname(const char *hostname, size_t len) { - //this function follows RFC 952 & RFC 1123 host name standards. //the hostname must be 32 chars or less and first and last char must be alphanumeric - if (!isalnum(hostname[0]) || !isalnum(hostname[len-1]) || len > 32) - { + if (len == 0 || len > 32 || !isalnum(hostname[0]) || !isalnum(hostname[len-1])){ return false; } - - for (int i=1; i