staging/ks7010: Remove all strcpy() uses in favor of strscpy()
authorLen Baker <len.baker@gmx.com>
Fri, 23 Jul 2021 14:51:22 +0000 (16:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Jul 2021 13:21:02 +0000 (15:21 +0200)
strcpy() performs no bounds checking on the destination buffer. This
could result in linear overflows beyond the end of the buffer, leading
to all kinds of misbehaviors. The safe replacement is strscpy().

Signed-off-by: Len Baker <len.baker@gmx.com>
Link: https://lore.kernel.org/r/20210723145122.5746-1-len.baker@gmx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ks7010/ks_wlan_net.c

index 09e7b4c..631ad76 100644 (file)
@@ -158,13 +158,13 @@ static int ks_wlan_get_name(struct net_device *dev,
 
        /* for SLEEP MODE */
        if (priv->dev_state < DEVICE_STATE_READY)
-               strcpy(cwrq->name, "NOT READY!");
+               strscpy(cwrq->name, "NOT READY!", sizeof(cwrq->name));
        else if (priv->reg.phy_type == D_11B_ONLY_MODE)
-               strcpy(cwrq->name, "IEEE 802.11b");
+               strscpy(cwrq->name, "IEEE 802.11b", sizeof(cwrq->name));
        else if (priv->reg.phy_type == D_11G_ONLY_MODE)
-               strcpy(cwrq->name, "IEEE 802.11g");
+               strscpy(cwrq->name, "IEEE 802.11g", sizeof(cwrq->name));
        else
-               strcpy(cwrq->name, "IEEE 802.11b/g");
+               strscpy(cwrq->name, "IEEE 802.11b/g", sizeof(cwrq->name));
 
        return 0;
 }
@@ -1808,8 +1808,8 @@ static int ks_wlan_get_firmware_version(struct net_device *dev,
 {
        struct ks_wlan_private *priv = netdev_priv(dev);
 
-       strcpy(extra, priv->firmware_version);
        dwrq->length = priv->version_size + 1;
+       strscpy(extra, priv->firmware_version, dwrq->length);
        return 0;
 }