[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D174755A8@AcuExch.aculab.com>
Date: Tue, 12 Aug 2014 08:43:33 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Jeff Kirsher' <jeffrey.t.kirsher@...el.com>,
"davem@...emloft.net" <davem@...emloft.net>
CC: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"nhorman@...hat.com" <nhorman@...hat.com>,
"sassmann@...hat.com" <sassmann@...hat.com>
Subject: RE: [net 4/6] i40e: Cleaning up missing null-terminate in
conjunction with strncpy
From: Jeff Kirsher
> From: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
>
> Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
...
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> index 2ac8f45..871474f 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
> @@ -4415,13 +4415,13 @@ static void i40e_print_link_message(struct i40e_vsi *vsi, bool isup)
>
> switch (vsi->back->hw.phy.link_info.link_speed) {
> case I40E_LINK_SPEED_40GB:
> - strncpy(speed, "40 Gbps", SPEED_SIZE);
> + strlcpy(speed, "40 Gbps", SPEED_SIZE);
> break;
> case I40E_LINK_SPEED_10GB:
> - strncpy(speed, "10 Gbps", SPEED_SIZE);
> + strlcpy(speed, "10 Gbps", SPEED_SIZE);
> break;
> case I40E_LINK_SPEED_1GB:
> - strncpy(speed, "1000 Mbps", SPEED_SIZE);
> + strlcpy(speed, "1000 Mbps", SPEED_SIZE);
> break;
> default:
> break;
Could 'speed' be change to be a 'const char *' ?
(and 'fc' below).
David
> @@ -4429,16 +4429,16 @@ static void i40e_print_link_message(struct i40e_vsi *vsi, bool isup)
>
> switch (vsi->back->hw.fc.current_mode) {
> case I40E_FC_FULL:
> - strncpy(fc, "RX/TX", FC_SIZE);
> + strlcpy(fc, "RX/TX", FC_SIZE);
> break;
> case I40E_FC_TX_PAUSE:
> - strncpy(fc, "TX", FC_SIZE);
> + strlcpy(fc, "TX", FC_SIZE);
> break;
> case I40E_FC_RX_PAUSE:
> - strncpy(fc, "RX", FC_SIZE);
> + strlcpy(fc, "RX", FC_SIZE);
> break;
> default:
> - strncpy(fc, "None", FC_SIZE);
> + strlcpy(fc, "None", FC_SIZE);
> break;
> }
>
> @@ -5839,7 +5839,7 @@ static void i40e_send_version(struct i40e_pf *pf)
> dv.minor_version = DRV_VERSION_MINOR;
> dv.build_version = DRV_VERSION_BUILD;
> dv.subbuild_version = 0;
> - strncpy(dv.driver_string, DRV_VERSION, sizeof(dv.driver_string));
> + strlcpy(dv.driver_string, DRV_VERSION, sizeof(dv.driver_string));
> i40e_aq_send_driver_version(&pf->hw, &dv, NULL);
> }
>
> --
> 1.9.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists