]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
i40e: use correct length for strncpy
authorMitch Williams <mitch.a.williams@intel.com>
Mon, 20 Aug 2018 15:12:30 +0000 (08:12 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 30 Aug 2018 20:53:04 +0000 (13:53 -0700)
Caught by GCC 8. When we provide a length for strncpy, we should not
include the terminating null. So we must tell it one less than the size
of the destination buffer.

Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_ptp.c

index 35f2866b38c6b921044d851f3898e342e048813f..1199f0502d6d5169fa211beb15f3b86331428582 100644 (file)
@@ -694,7 +694,8 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf)
        if (!IS_ERR_OR_NULL(pf->ptp_clock))
                return 0;
 
-       strncpy(pf->ptp_caps.name, i40e_driver_name, sizeof(pf->ptp_caps.name));
+       strncpy(pf->ptp_caps.name, i40e_driver_name,
+               sizeof(pf->ptp_caps.name) - 1);
        pf->ptp_caps.owner = THIS_MODULE;
        pf->ptp_caps.max_adj = 999999999;
        pf->ptp_caps.n_ext_ts = 0;