hardened WiFi-String stuff
This commit is contained in:
@@ -102,7 +102,6 @@ uint32_t Checksum_EEPROM(uint8_t const *data, size_t len);
|
||||
void dumpEEPROM(uint16_t memoryAddress, uint16_t length);
|
||||
void MovePersistencePage_EEPROM(boolean reset);
|
||||
uint32_t ConfigSanityCheck(bool autocorrect = false);
|
||||
bool validateWiFiString(char *string, size_t size);
|
||||
void writeSequentialToEEPROM(uint16_t memoryAddress, uint16_t length);
|
||||
void writeZeroToEEPROM(uint16_t memoryAddress, uint16_t length);
|
||||
|
||||
|
@@ -10,7 +10,7 @@ typedef struct Globals_s
|
||||
tSystem_Status resumeStatus = sysStat_Startup; /**< Status to resume after rain mode */
|
||||
char systemStatustxt[16] = ""; /**< Text representation of system status */
|
||||
EERequest_t requestEEAction = EE_IDLE; /**< EEPROM-related request */
|
||||
char DeviceName[33]; /**< Device name */
|
||||
char DeviceName[25]; /**< Device name */
|
||||
char DeviceNameId[sizeof(DeviceName) + 8]; /**< Device name plus 8 chars chipID */
|
||||
char FlashVersion[10]; /**< Flash version */
|
||||
uint16_t eePersistanceAdress; /**< EEPROM persistence address */
|
||||
|
36
Software/include/utilities.h
Normal file
36
Software/include/utilities.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef UTILITIES_H
|
||||
#define UTILITIES_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
/**
|
||||
* @brief Validates whether a given string contains only characters allowed in WiFi SSIDs and passwords.
|
||||
*
|
||||
* This function checks each character in the provided string to ensure
|
||||
* that it contains only characters allowed in WiFi SSIDs and passwords.
|
||||
* It considers characters from 'A' to 'Z', 'a' to 'z', '0' to '9', as well as
|
||||
* the following special characters: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
|
||||
*
|
||||
* @param string Pointer to the string to be validated.
|
||||
* @param size Size of the string including the null-terminator.
|
||||
* @return true if the string contains only allowed characters or is NULL,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool validateWiFiString(char *string, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Copies a string to a buffer, replacing invalid WiFi SSID characters with a placeholder.
|
||||
*
|
||||
* This function checks each character in the provided input string to ensure
|
||||
* that it contains only characters allowed in WiFi SSIDs and passwords. If a character
|
||||
* is invalid, it replaces it with a placeholder character (e.g., '_').
|
||||
* It considers characters from 'A' to 'Z', 'a' to 'z', '0' to '9', as well as
|
||||
* the following special characters: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
|
||||
*
|
||||
* @param input Pointer to the input string to be validated and copied.
|
||||
* @param buffer Pointer to the buffer where the output string will be copied.
|
||||
* @param bufferSize Size of the buffer including the null-terminator.
|
||||
*/
|
||||
void sanitizeWiFiString(const char *input, char *buffer, size_t bufferSize);
|
||||
|
||||
#endif // UTILITIES_H
|
Reference in New Issue
Block a user