diff --git a/sonoff/support.ino b/sonoff/support.ino index cffcb4690..f060a551b 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -207,9 +207,8 @@ char* ulltoa(unsigned long long value, char *str, int radix) int i = 0; int n = 0; -/* - if (radix < 2 || radix > 36) { radix = 10; } -*/ +// if (radix < 2 || radix > 36) { radix = 10; } + do { n = value % radix; digits[i++] = (n < 10) ? (char)n+'0' : (char)n-10+'A'; @@ -396,7 +395,7 @@ bool ValidIpAddress(const char* str) { const char* p = str; - while (*p && ( (*p == '.') || (*p >= '0') || (*p <= '9') )) { p++; } + while (*p && ((*p == '.') || ((*p >= '0') && (*p <= '9')))) { p++; } return (*p == '\0'); } diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index 76cdae534..771a010b1 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -2148,6 +2148,7 @@ void HandleNotFound(void) /* Redirect to captive portal if we got a request for another domain. Return true in that case so the page handler do not try to handle the request again. */ bool CaptivePortal(void) { + // Possible hostHeader: connectivitycheck.gstatic.com or 192.168.4.1 if ((WifiIsInManagerMode()) && !ValidIpAddress(WebServer->hostHeader().c_str())) { AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_REDIRECTED));