net/mrvl: fix build error with gcc
PATCH 1/1 net/mrvl: fix build error with gcc
gcc version:
aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011
build error:
CC mrvl_qos.o.../drivers/net/mrvl/mrvl_qos.c: In function ‘mrvl_configure_rxqs’:.../drivers/net/mrvl/mrvl_qos.c:679:17:
error: ‘sprintf’ may write a terminating nul past the end of the
destination [-Werror=format-overflow=]
sprintf(match, "policer-%d:%d\n", priv->pp_id, priv->ppio_id);
^~~~~~~~~~~~~~~~~.../drivers/net/mrvl/mrvl_qos.c:679:2:
note: ‘sprintf’ output between 13 and 17 bytes into a destination
of size 16
sprintf(match, "policer-%d:%d\n", priv->pp_id, priv->ppio_id); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixed by replacing sprintf to snprintf.
---
--- drivers/net/mrvl/mrvl_qos.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mrvl/mrvl_qos.c +2 -1
@@ -676,7 +676,8 @@ setup_policer(struct mrvl_priv *priv, struct pp2_cls_plcr_params *params)char match[16 ];int ret; -sprintf (match,"policer-%d:%d\n" , priv->pp_id, priv->ppio_id); +snprintf (match,sizeof (match),"policer-%d:%d\n" , + priv->pp_id, priv->ppio_id); params->match = match; ret =pp2_cls_plcr_init (params, &priv->policer);
Signature · 1 line
2.13.6
Quoted 43 lines · Ferruh Yigit
gcc version:
aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011build error:
CC mrvl_qos.o.../drivers/net/mrvl/mrvl_qos.c: In function ‘mrvl_configure_rxqs’:.../drivers/net/mrvl/mrvl_qos.c:679:17:
error: ‘sprintf’ may write a terminating nul past the end of the
destination [-Werror=format-overflow=]sprintf(match, "policer-%d:%d\n", priv->pp_id, priv->ppio_id); ^~~~~~~~~~~~~~~~~
.../drivers/net/mrvl/mrvl_qos.c:679:2:
note: ‘sprintf’ output between 13 and 17 bytes into a destination
of size 16
sprintf(match, "policer-%d:%d\n", priv->pp_id, priv->ppio_id); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Fixed by replacing sprintf to snprintf.
Fixes 8860fd7b70f0 ("net/mrvl: add ingress policer support")Signed-off-by Ferruh Yigit <[email protected]>---
--- drivers/net/mrvl/mrvl_qos.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/mrvl/mrvl_qos.c +2
-2@@ -676,7 +676,8 @@ setup_policer(struct mrvl_priv *priv, struct pp2_cls_plcr_params *params)char match[16 ];int ret; -sprintf (match,"policer-%d:%d\n" , priv->pp_id, priv->ppio_id); +snprintf (match,sizeof (match),"policer-%d:%d\n" , + priv->pp_id, priv->ppio_id); params->match = match; ret =pp2_cls_plcr_init (params, &priv->policer); --
Quoted 2 lines
2.13.6
--
- Tomasz Duszyński
Quoted 18 lines · Tomasz Duszynski
Quoted 17 lines · Ferruh Yigit
gcc version:
aarch64-linux-gnu-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011build error:
CC mrvl_qos.o.../drivers/net/mrvl/mrvl_qos.c: In function ‘mrvl_configure_rxqs’:.../drivers/net/mrvl/mrvl_qos.c:679:17:
error: ‘sprintf’ may write a terminating nul past the end of the
destination [-Werror=format-overflow=]sprintf(match, "policer-%d:%d\n", priv->pp_id, priv->ppio_id); ^~~~~~~~~~~~~~~~~
.../drivers/net/mrvl/mrvl_qos.c:679:2:
note: ‘sprintf’ output between 13 and 17 bytes into a destination
of size 16
sprintf(match, "policer-%d:%d\n", priv->pp_id, priv->ppio_id); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 8 lines
Quoted 6 lines
Fixed by replacing sprintf to snprintf.
Fixes 8860fd7b70f0 ("net/mrvl: add ingress policer support")Signed-off-by Ferruh Yigit <[email protected]>Acked-by Tomasz Duszynski <[email protected]>
Squashed into relevant commit in next-net, thanks.