Skip to contentSkip to conversation

net/mrvl: fix build error with gcc

PATCH In review Ferruh Yigit 2 participants 3 messages Mar 22, 2018 – Mar 27, 2018 Network drivers

lore
Share & tools
lore
#0 lore raw

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.

Fixes 8860fd7b70f0 ("net/mrvl: add ingress policer support")

---

---
 drivers/net/mrvl/mrvl_qos.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mrvl/mrvl_qos.c +2 -1
index e9c4531fd..741d3da7a 100644
@@ -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
Acked-by on v1 1/1
#1 lore raw
Quoted 43 lines · Ferruh Yigit

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.

Fixes 8860fd7b70f0 ("net/mrvl: add ingress policer support")

---

---
 drivers/net/mrvl/mrvl_qos.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mrvl/mrvl_qos.c +2 -2
index e9c4531fd..741d3da7a 100644
@@ -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

#2 lore raw
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 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); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 8 lines
Quoted 6 lines

Fixed by replacing sprintf to snprintf.

Fixes 8860fd7b70f0 ("net/mrvl: add ingress policer support")

Squashed into relevant commit in next-net, thanks.