Incorrect lengths in wifi_ap_config_t for SSID and WFA-PSK

mikkojaakkola
Posts: 5
Joined: Fri Aug 02, 2019 3:03 am

Incorrect lengths in wifi_ap_config_t for SSID and WFA-PSK

Postby mikkojaakkola » Fri Aug 02, 2019 3:16 am

  1. typedef struct {
  2.     uint8_t ssid[32];      /**< SSID of target AP. Null terminated string. */
  3.     uint8_t password[64];  /**< Password of target AP. Null terminated string.*/
  4.     wifi_scan_method_t scan_method;    /**< do all channel scan or fast scan */
  5.     bool bssid_set;        /**< whether set MAC address of target AP or not. Generally, station_config.bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.*/
  6.     uint8_t bssid[6];     /**< MAC address of target AP*/
  7.     uint8_t channel;       /**< channel of target AP. Set to 1~13 to scan starting from the specified channel before connecting to AP. If the channel of AP is unknown, set it to 0.*/
  8.     uint16_t listen_interval;   /**< Listen interval for ESP32 station to receive beacon when WIFI_PS_MAX_MODEM is set. Units: AP beacon intervals. Defaults to 3 if set to 0. */
  9.     wifi_sort_method_t sort_method;    /**< sort the connect AP in the list by rssi or security mode */
  10.     wifi_scan_threshold_t  threshold;     /**< When scan_method is set, only APs which have an auth mode that is more secure than the selected auth mode and a signal stronger than the minimum RSSI will be used. */
  11. } wifi_sta_config_t;
  12.  
It looks like SSID length is 32 per standard but requires null-termination so the size of the array should be 33.

The same issue is with password that should be 65 bytes long assuming it is null-terminated string.

Not major issue in the most cases but especially in machine generated passwords, one could easily get bitten by this.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Incorrect lengths in wifi_ap_config_t for SSID and WFA-PSK

Postby WiFive » Fri Aug 02, 2019 6:59 am

They have to be null terminated if they are not full length

mikkojaakkola
Posts: 5
Joined: Fri Aug 02, 2019 3:03 am

Re: Incorrect lengths in wifi_ap_config_t for SSID and WFA-PSK

Postby mikkojaakkola » Fri Aug 02, 2019 6:35 pm

Let's me try to understand the response. Are you saying that code is checking SSID up to null OR to the maximum length? The documentation is pretty clear stating that SSID and password needs to be null-terminated but I guess that's not the case if they are maximum length, right?

Who is online

Users browsing this forum: ok-home and 121 guests