DPP: Fix bootstrapping URI parser to handle channel list for an opclass

The bootstrapping URI format for DPP was extended during protocol design
to allow a list of channels without having to repeat the same operating
class information for each channel. That change was not included in the
initial implementation of the parser and a channel-list like
"C:81/1,6,11" would not be understood correctly (i.e., only the longer
"C:81/1,81/6,81/11" form would have been parsed correctly).

Fix this by extending the parser to accept both the shorter and longer
form for a list of channels within a single operating class.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2019-05-23 01:34:24 +03:00 committed by Jouni Malinen
parent 69afb6b395
commit b1aee7a622

View file

@ -745,17 +745,19 @@ static int dpp_clone_uri(struct dpp_bootstrap_info *bi, const char *uri)
int dpp_parse_uri_chan_list(struct dpp_bootstrap_info *bi,
const char *chan_list)
{
const char *pos = chan_list;
int opclass, channel, freq;
const char *pos = chan_list, *pos2;
int opclass = -1, channel, freq;
while (pos && *pos && *pos != ';') {
opclass = atoi(pos);
pos2 = pos;
while (*pos2 >= '0' && *pos2 <= '9')
pos2++;
if (*pos2 == '/') {
opclass = atoi(pos);
pos = pos2 + 1;
}
if (opclass <= 0)
goto fail;
pos = os_strchr(pos, '/');
if (!pos)
goto fail;
pos++;
channel = atoi(pos);
if (channel <= 0)
goto fail;