driver_ralink: Use os_strlcpy instead of os_strncpy to ensure null
termination
This commit is contained in:
parent
d04cbdd640
commit
5e77500c4f
1 changed files with 10 additions and 10 deletions
|
@ -57,7 +57,7 @@ static int ralink_set_oid(struct wpa_driver_ralink_data *drv,
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
os_memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
||||||
iwr.u.data.flags = oid;
|
iwr.u.data.flags = oid;
|
||||||
iwr.u.data.flags |= OID_GET_SET_TOGGLE;
|
iwr.u.data.flags |= OID_GET_SET_TOGGLE;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ ralink_get_new_driver_flag(struct wpa_driver_ralink_data *drv)
|
||||||
UCHAR enabled = 0;
|
UCHAR enabled = 0;
|
||||||
|
|
||||||
os_memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
||||||
iwr.u.data.pointer = (UCHAR*) &enabled;
|
iwr.u.data.pointer = (UCHAR*) &enabled;
|
||||||
iwr.u.data.flags = RT_OID_NEW_DRIVER;
|
iwr.u.data.flags = RT_OID_NEW_DRIVER;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ static int wpa_driver_ralink_get_bssid(void *priv, u8 *bssid)
|
||||||
wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
|
wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
|
||||||
|
|
||||||
os_memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
||||||
|
|
||||||
if (ioctl(drv->ioctl_sock, SIOCGIWAP, &iwr) < 0) {
|
if (ioctl(drv->ioctl_sock, SIOCGIWAP, &iwr) < 0) {
|
||||||
perror("ioctl[SIOCGIWAP]");
|
perror("ioctl[SIOCGIWAP]");
|
||||||
|
@ -145,7 +145,7 @@ static int wpa_driver_ralink_get_ssid(void *priv, u8 *ssid)
|
||||||
wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
|
wpa_printf(MSG_DEBUG, "%s", __FUNCTION__);
|
||||||
|
|
||||||
os_memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
||||||
iwr.u.essid.pointer = (caddr_t) ssid;
|
iwr.u.essid.pointer = (caddr_t) ssid;
|
||||||
iwr.u.essid.length = 32;
|
iwr.u.essid.length = 32;
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ static int wpa_driver_ralink_set_ssid(struct wpa_driver_ralink_data *drv,
|
||||||
buf->SsidLength = ssid_len;
|
buf->SsidLength = ssid_len;
|
||||||
os_memcpy(buf->Ssid, ssid, ssid_len);
|
os_memcpy(buf->Ssid, ssid, ssid_len);
|
||||||
os_memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
||||||
|
|
||||||
iwr.u.data.flags = OID_802_11_SSID;
|
iwr.u.data.flags = OID_802_11_SSID;
|
||||||
iwr.u.data.flags |= OID_GET_SET_TOGGLE;
|
iwr.u.data.flags |= OID_GET_SET_TOGGLE;
|
||||||
|
@ -839,7 +839,7 @@ ralink_get_we_version_compiled(struct wpa_driver_ralink_data *drv)
|
||||||
UINT we_version_compiled = 0;
|
UINT we_version_compiled = 0;
|
||||||
|
|
||||||
os_memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
||||||
iwr.u.data.pointer = (caddr_t) &we_version_compiled;
|
iwr.u.data.pointer = (caddr_t) &we_version_compiled;
|
||||||
iwr.u.data.flags = RT_OID_WE_VERSION_COMPILED;
|
iwr.u.data.flags = RT_OID_WE_VERSION_COMPILED;
|
||||||
|
|
||||||
|
@ -901,7 +901,7 @@ static void * wpa_driver_ralink_init(void *ctx, const char *ifname)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* do it */
|
/* do it */
|
||||||
os_strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
||||||
|
|
||||||
if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
|
if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
|
||||||
perror(ifr.ifr_name);
|
perror(ifr.ifr_name);
|
||||||
|
@ -915,7 +915,7 @@ static void * wpa_driver_ralink_init(void *ctx, const char *ifname)
|
||||||
drv->scanning_done = 1;
|
drv->scanning_done = 1;
|
||||||
drv->ap_scan = 1; /* for now - let's assume ap_scan=1 is used */
|
drv->ap_scan = 1; /* for now - let's assume ap_scan=1 is used */
|
||||||
drv->ctx = ctx;
|
drv->ctx = ctx;
|
||||||
os_strncpy(drv->ifname, ifname, sizeof(drv->ifname));
|
os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname));
|
||||||
drv->ioctl_sock = s;
|
drv->ioctl_sock = s;
|
||||||
drv->g_driver_down = 0;
|
drv->g_driver_down = 0;
|
||||||
|
|
||||||
|
@ -1037,7 +1037,7 @@ static int wpa_driver_ralink_scan(void *priv, const u8 *ssid, size_t ssid_len)
|
||||||
/* wpa_driver_ralink_set_ssid(drv, ssid, ssid_len); */
|
/* wpa_driver_ralink_set_ssid(drv, ssid, ssid_len); */
|
||||||
|
|
||||||
os_memset(&iwr, 0, sizeof(iwr));
|
os_memset(&iwr, 0, sizeof(iwr));
|
||||||
os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
||||||
|
|
||||||
if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
|
if (ioctl(drv->ioctl_sock, SIOCSIWSCAN, &iwr) < 0) {
|
||||||
perror("ioctl[SIOCSIWSCAN]");
|
perror("ioctl[SIOCSIWSCAN]");
|
||||||
|
@ -1086,7 +1086,7 @@ wpa_driver_ralink_get_scan_results(void *priv,
|
||||||
wsr = (NDIS_802_11_BSSID_LIST_EX *) buf;
|
wsr = (NDIS_802_11_BSSID_LIST_EX *) buf;
|
||||||
|
|
||||||
wsr->NumberOfItems = 0;
|
wsr->NumberOfItems = 0;
|
||||||
os_strncpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
os_strlcpy(iwr.ifr_name, drv->ifname, IFNAMSIZ);
|
||||||
iwr.u.data.pointer = (void *) buf;
|
iwr.u.data.pointer = (void *) buf;
|
||||||
iwr.u.data.flags = OID_802_11_BSSID_LIST;
|
iwr.u.data.flags = OID_802_11_BSSID_LIST;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue