Hi Michael, Michael Hunter wrote:
>In wpa_config_parse_ssid() ssid is set to the strdup(value) and >ssid_len is set to the strlen(value). ssid_len is checked to be <= >MAX_ESSID_LENGTH. I think that should probably be < so you can fit in >the termination or the constant should be renamed. I don't see an >obvious place where this is an issue around this code but I'm not >convinced that it is easy for the reader to figure out what your >conventions are (although there are clearly some +1s around that make >the above work). FWIW I tend to use max to mean the max of the value >and len to mean the length (amount) of storage including termination, >quoteing, etc. But in any case what convention you choose is up to you >although it should really be chosen to make the readers job easier. > > The buf defined as "+1s" - "char buf[MAX_ESSID_LENGTH + 1]" is intentional. The MAX_ESSID_LENGTH is defined as 32 by IEEE802.11 specification, it's fixed value, it didn't contain the termination, so we have to +1s. If we choose to define MAX_ESSID_LENGTH as 33, and define buf as buf[MAX_ESSID_LENGTH], it will really confuse readers because they know the MAX_ESSID_LENGTH should be 32. Besides, the MAX_ESSID_LENGTH is defined in "wifi_ioctl.h", it's also used by others. -- Quaker
