Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert lengths for AP factory settings #279

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/framework/APSettingsService.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include <DNSServer.h>
#include <IPAddress.h>

#define CHECK_LEN(s, min_len, max_len) \
static_assert(min_len <= sizeof(s) && sizeof(s) <= max_len, #s " should have " #min_len "-" #max_len " characters.")

#ifndef FACTORY_AP_PROVISION_MODE
#define FACTORY_AP_PROVISION_MODE AP_MODE_DISCONNECTED
#endif
Expand All @@ -17,10 +20,14 @@
#define FACTORY_AP_SSID "ESP8266-React-#{unique_id}"
#endif

CHECK_LEN(FACTORY_AP_SSID, 1, 64);

#ifndef FACTORY_AP_PASSWORD
#define FACTORY_AP_PASSWORD "esp-react"
#endif

CHECK_LEN(FACTORY_AP_PASSWORD, 8, 64);

#ifndef FACTORY_AP_LOCAL_IP
#define FACTORY_AP_LOCAL_IP "192.168.4.1"
#endif
Expand Down