aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2003-07-11 11:25:58 (GMT)
committerJouni Malinen <j@w1.fi>2003-07-11 11:25:58 (GMT)
commit09a9ab838671aa091184fbea7194f44f6617698c (patch)
tree1461ffc4468979e09cb4d094cbfc0a54f78cc627
parent5305171d79eaba98fdde32e9f1c8208f3afa6a81 (diff)
downloadhostap-history-09a9ab838671aa091184fbea7194f44f6617698c.zip
hostap-history-09a9ab838671aa091184fbea7194f44f6617698c.tar.gz
hostap-history-09a9ab838671aa091184fbea7194f44f6617698c.tar.bz2
Cleaned up SSID use: do not store extra +1 in ssid_len. Only add it when
doing ioctl() to match iwconfig behavior.
-rw-r--r--hostapd/config.c8
-rw-r--r--hostapd/config.h4
-rw-r--r--hostapd/driver.c2
-rw-r--r--hostapd/ieee802_11.c2
4 files changed, 8 insertions, 8 deletions
diff --git a/hostapd/config.c b/hostapd/config.c
index e950ca9..b7f2160 100644
--- a/hostapd/config.c
+++ b/hostapd/config.c
@@ -33,8 +33,8 @@ static struct hostapd_config *hostapd_config_defaults(void)
}
memset(conf, 0, sizeof(*conf));
- conf->ssid_len = 5;
- strncpy(conf->ssid, "test", sizeof(conf->ssid) - 1);
+ conf->ssid_len = 4;
+ memcpy(conf->ssid, "test", 4);
conf->wep_rekeying_period = 300;
conf->logger_syslog_level = HOSTAPD_LEVEL_INFO;
@@ -216,14 +216,14 @@ struct hostapd_config * hostapd_config_read(const char *fname)
conf->daemonize = atoi(pos);
} else if (strcmp(buf, "ssid") == 0) {
conf->ssid_len = strlen(pos);
- if (conf->ssid_len >= sizeof(conf->ssid) ||
+ if (conf->ssid_len >= HOSTAPD_SSID_LEN ||
conf->ssid_len < 1) {
printf("Line %d: invalid SSID '%s'\n", line,
pos);
errors++;
}
- conf->ssid_len++; /* FIX: get rid of this.. */
memcpy(conf->ssid, pos, conf->ssid_len);
+ conf->ssid[conf->ssid_len] = '\0';
} else if (strcmp(buf, "macaddr_acl") == 0) {
conf->macaddr_acl = atoi(pos);
if (conf->macaddr_acl != ACCEPT_UNLESS_DENIED &&
diff --git a/hostapd/config.h b/hostapd/config.h
index f958f32..c6a5e48 100644
--- a/hostapd/config.h
+++ b/hostapd/config.h
@@ -45,8 +45,8 @@ struct hostapd_config {
int num_acct_servers;
int radius_retry_primary_interval;
-
- char ssid[33];
+#define HOSTAPD_SSID_LEN 32
+ char ssid[HOSTAPD_SSID_LEN + 1];
size_t ssid_len;
char *eap_req_id_text; /* optional displayable message sent with
* EAP Request-Identity */
diff --git a/hostapd/driver.c b/hostapd/driver.c
index b66430f..3a1c492 100644
--- a/hostapd/driver.c
+++ b/hostapd/driver.c
@@ -155,7 +155,7 @@ int hostap_ioctl_setiwessid(hostapd *hapd, char *buf, int len)
strncpy(iwr.ifr_name, hapd->conf->iface, IFNAMSIZ);
iwr.u.essid.flags = 1; /* SSID active */
iwr.u.essid.pointer = (caddr_t) buf;
- iwr.u.essid.length = len;
+ iwr.u.essid.length = len + 1;
if (ioctl(hapd->ioctl_sock, SIOCSIWESSID, &iwr) < 0) {
perror("ioctl[SIOCSIWESSID]");
diff --git a/hostapd/ieee802_11.c b/hostapd/ieee802_11.c
index 4374288..edb65ba 100644
--- a/hostapd/ieee802_11.c
+++ b/hostapd/ieee802_11.c
@@ -575,7 +575,7 @@ static void handle_assoc(hostapd *hapd, struct ieee80211_mgmt *mgmt,
goto fail;
}
- if (elems.ssid_len != hapd->conf->ssid_len - 1 ||
+ if (elems.ssid_len != hapd->conf->ssid_len ||
memcmp(elems.ssid, hapd->conf->ssid, elems.ssid_len) != 0) {
printf("Station " MACSTR " tried to associate with "
"unknown SSID '", MAC2STR(sta->addr));