From 5e77500c4f634a6db68e5fba9db688669b21edda Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 27 Feb 2008 17:52:43 -0800 Subject: [PATCH] driver_ralink: Use os_strlcpy instead of os_strncpy to ensure null termination --- src/drivers/driver_ralink.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/drivers/driver_ralink.c b/src/drivers/driver_ralink.c index 73fa94830..27cae0bc6 100644 --- a/src/drivers/driver_ralink.c +++ b/src/drivers/driver_ralink.c @@ -57,7 +57,7 @@ static int ralink_set_oid(struct wpa_driver_ralink_data *drv, if (buf == NULL) return -1; 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_GET_SET_TOGGLE; @@ -84,7 +84,7 @@ ralink_get_new_driver_flag(struct wpa_driver_ralink_data *drv) UCHAR enabled = 0; 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.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__); 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) { perror("ioctl[SIOCGIWAP]"); @@ -145,7 +145,7 @@ static int wpa_driver_ralink_get_ssid(void *priv, u8 *ssid) wpa_printf(MSG_DEBUG, "%s", __FUNCTION__); 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.length = 32; @@ -236,7 +236,7 @@ static int wpa_driver_ralink_set_ssid(struct wpa_driver_ralink_data *drv, buf->SsidLength = ssid_len; os_memcpy(buf->Ssid, ssid, ssid_len); 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_GET_SET_TOGGLE; @@ -839,7 +839,7 @@ ralink_get_we_version_compiled(struct wpa_driver_ralink_data *drv) UINT we_version_compiled = 0; 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.flags = RT_OID_WE_VERSION_COMPILED; @@ -901,7 +901,7 @@ static void * wpa_driver_ralink_init(void *ctx, const char *ifname) return NULL; } /* do it */ - os_strncpy(ifr.ifr_name, ifname, IFNAMSIZ); + os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ); if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) { perror(ifr.ifr_name); @@ -915,7 +915,7 @@ static void * wpa_driver_ralink_init(void *ctx, const char *ifname) drv->scanning_done = 1; drv->ap_scan = 1; /* for now - let's assume ap_scan=1 is used */ drv->ctx = ctx; - os_strncpy(drv->ifname, ifname, sizeof(drv->ifname)); + os_strlcpy(drv->ifname, ifname, sizeof(drv->ifname)); drv->ioctl_sock = s; 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); */ 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) { perror("ioctl[SIOCSIWSCAN]"); @@ -1086,7 +1086,7 @@ wpa_driver_ralink_get_scan_results(void *priv, wsr = (NDIS_802_11_BSSID_LIST_EX *) buf; 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.flags = OID_802_11_BSSID_LIST;