nvethernet: use safe version of sprintf

Issue: possible buffer overrun with sprintf()

Fix: Use scnprintf() instead of sprintf()

Bug 2715372

Change-Id: Ie3564bc41831ed8acf5b40d8a9f5a12e65cdc98a
Signed-off-by: Mahesh Patil <maheshp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2240400
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bhadram Varka <vbhadram@nvidia.com>
Reviewed-by: Narayan Reddy <narayanr@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ashutosh Jha <ajha@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Mahesh Patil
2019-11-15 16:51:38 -08:00
committed by Revanth Kumar Uppala
parent a1df5ed4a8
commit 03465c3c14

View File

@@ -33,8 +33,9 @@ static ssize_t ether_mac_loopback_show(struct device *dev,
struct net_device *ndev = (struct net_device *)dev_get_drvdata(dev);
struct ether_priv_data *pdata = netdev_priv(ndev);
return sprintf(buf, "%s\n", (pdata->mac_loopback_mode == 1) ?
"enabled" : "disabled");
return scnprintf(buf, PAGE_SIZE, "%s\n",
(pdata->mac_loopback_mode == 1U) ?
"enabled" : "disabled");
}
/**