Fix GCC format-security errors and convert sprintfs.
With format-security errors turned on, GCC picks up the use of sprintf with
a format parameter not being a string literal.
Simple uses of sprintf are also converted to use strcpy.
Signed-off-by: Ben Whitten <ben.whitten@gmail.com>
Acked-by: Wolfgang Denk <wd@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
diff --git a/drivers/block/sata_dwc.c b/drivers/block/sata_dwc.c
index 9e8b067..b14985a 100644
--- a/drivers/block/sata_dwc.c
+++ b/drivers/block/sata_dwc.c
@@ -626,7 +626,7 @@
if (id[162] & 1)
printf("supports DRM functions and may "
"not be fully accessable.\n");
- sprintf(revbuf, "%s", "CFA");
+ strcpy(revbuf, "CFA");
} else {
if (ata_id_has_tpm(id))
printf("supports DRM functions and may "
@@ -653,7 +653,7 @@
ncq_desc[0] = '\0';
if (ata_dev->horkage & ATA_HORKAGE_NONCQ)
- sprintf(ncq_desc, "%s", "NCQ (not used)");
+ strcpy(ncq_desc, "NCQ (not used)");
if (ap.flags & ATA_FLAG_NCQ)
ata_dev->flags |= ATA_DFLAG_NCQ;
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index 3eaa270..92a1b64 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -417,7 +417,7 @@
bus->read = tse_mdio_read;
bus->write = tse_mdio_write;
- snprintf(bus->name, sizeof(bus->name), name);
+ snprintf(bus->name, sizeof(bus->name), "%s", name);
bus->priv = (void *)priv;
diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
index d51e098..2659592 100644
--- a/drivers/net/at91_emac.c
+++ b/drivers/net/at91_emac.c
@@ -490,7 +490,7 @@
memset(emacfix, 0, sizeof(emac_device));
memset(dev, 0, sizeof(*dev));
- sprintf(dev->name, "emac");
+ strcpy(dev->name, "emac");
dev->iobase = iobase;
dev->priv = emacfix;
dev->init = at91emac_init;
diff --git a/drivers/net/ax88180.c b/drivers/net/ax88180.c
index ded9e06..43a67a5 100644
--- a/drivers/net/ax88180.c
+++ b/drivers/net/ax88180.c
@@ -722,7 +722,7 @@
memset (priv, 0, sizeof *priv);
- sprintf (dev->name, "ax88180");
+ strcpy(dev->name, "ax88180");
dev->iobase = AX88180_BASE;
dev->priv = priv;
dev->init = ax88180_init;
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 3dff9df..7104754 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -567,7 +567,7 @@
bus->read = cpsw_mdio_read;
bus->write = cpsw_mdio_write;
- sprintf(bus->name, name);
+ strcpy(bus->name, name);
mdio_register(bus);
}
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 0444795..92c3dca 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -777,7 +777,7 @@
return -1;
memset(dev, 0, sizeof *dev);
- sprintf(dev->name, "DaVinci-EMAC");
+ strcpy(dev->name, "DaVinci-EMAC");
dev->iobase = 0;
dev->init = davinci_eth_open;
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 0fccbc0..68b6548 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -81,7 +81,7 @@
bus->read = dw_mdio_read;
bus->write = dw_mdio_write;
- snprintf(bus->name, sizeof(bus->name), name);
+ snprintf(bus->name, sizeof(bus->name), "%s", name);
bus->priv = (void *)mac_regs_p;
diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 3c41cec..93c6667 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -630,7 +630,7 @@
dev->halt = dm9000_halt;
dev->send = dm9000_send;
dev->recv = dm9000_rx;
- sprintf(dev->name, "dm9000");
+ strcpy(dev->name, "dm9000");
eth_register(dev);
diff --git a/drivers/net/fm/memac_phy.c b/drivers/net/fm/memac_phy.c
index 4ab78e6..5079342 100644
--- a/drivers/net/fm/memac_phy.c
+++ b/drivers/net/fm/memac_phy.c
@@ -146,7 +146,7 @@
bus->read = memac_mdio_read;
bus->write = memac_mdio_write;
bus->reset = memac_mdio_reset;
- sprintf(bus->name, info->name);
+ strcpy(bus->name, info->name);
bus->priv = info->regs;
diff --git a/drivers/net/fm/tgec_phy.c b/drivers/net/fm/tgec_phy.c
index 24cb17b..f038541 100644
--- a/drivers/net/fm/tgec_phy.c
+++ b/drivers/net/fm/tgec_phy.c
@@ -118,7 +118,7 @@
bus->read = tgec_mdio_read;
bus->write = tgec_mdio_write;
bus->reset = tgec_mdio_reset;
- sprintf(bus->name, info->name);
+ strcpy(bus->name, info->name);
bus->priv = info->regs;
diff --git a/drivers/net/fsl_mdio.c b/drivers/net/fsl_mdio.c
index d6b181b..f48bbc3 100644
--- a/drivers/net/fsl_mdio.c
+++ b/drivers/net/fsl_mdio.c
@@ -104,7 +104,7 @@
bus->read = tsec_phy_read;
bus->write = tsec_phy_write;
bus->reset = fsl_pq_mdio_reset;
- sprintf(bus->name, info->name);
+ strcpy(bus->name, info->name);
bus->priv = (void *)info->regs;
diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c
index 515f0b2..5ccc4be 100644
--- a/drivers/net/ftgmac100.c
+++ b/drivers/net/ftgmac100.c
@@ -562,7 +562,7 @@
memset(dev, 0, sizeof(*dev));
memset(priv, 0, sizeof(*priv));
- sprintf(dev->name, "FTGMAC100");
+ strcpy(dev->name, "FTGMAC100");
dev->iobase = CONFIG_FTGMAC100_BASE;
dev->init = ftgmac100_init;
dev->halt = ftgmac100_halt;
diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c
index bd94f83..1fc7da9 100644
--- a/drivers/net/ftmac100.c
+++ b/drivers/net/ftmac100.c
@@ -246,7 +246,7 @@
memset (dev, 0, sizeof (*dev));
memset (priv, 0, sizeof (*priv));
- sprintf (dev->name, "FTMAC100");
+ strcpy(dev->name, "FTMAC100");
dev->iobase = CONFIG_FTMAC100_BASE;
dev->init = ftmac100_init;
dev->halt = ftmac100_halt;
diff --git a/drivers/net/greth.c b/drivers/net/greth.c
index 088cb22..aa5d711 100644
--- a/drivers/net/greth.c
+++ b/drivers/net/greth.c
@@ -640,9 +640,9 @@
/* Make descriptor string */
if (greth->gbit_mac) {
- sprintf(dev->name, "GRETH_10/100/GB");
+ strcpy(dev->name, "GRETH_10/100/GB");
} else {
- sprintf(dev->name, "GRETH_10/100");
+ strcpy(dev->name, "GRETH_10/100");
}
/* initiate PHY, select speed/duplex depending on connected PHY */
diff --git a/drivers/net/keystone_net.c b/drivers/net/keystone_net.c
index 24ca52e..209fae9 100644
--- a/drivers/net/keystone_net.c
+++ b/drivers/net/keystone_net.c
@@ -586,7 +586,7 @@
mdio_bus->write = keystone2_mdio_write;
mdio_bus->reset = keystone2_mdio_reset;
mdio_bus->priv = (void *)EMAC_MDIO_BASE_ADDR;
- sprintf(mdio_bus->name, "ethernet-mdio");
+ strcpy(mdio_bus->name, "ethernet-mdio");
res = mdio_register(mdio_bus);
if (res)
diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c
index 69530b1..3857122 100644
--- a/drivers/net/ldpaa_eth/ldpaa_eth.c
+++ b/drivers/net/ldpaa_eth/ldpaa_eth.c
@@ -628,11 +628,11 @@
#endif
memset(&dpmac_endpoint, 0, sizeof(struct dprc_endpoint));
- sprintf(dpmac_endpoint.type, "dpmac");
+ strcpy(dpmac_endpoint.type, "dpmac");
dpmac_endpoint.id = priv->dpmac_id;
memset(&dpni_endpoint, 0, sizeof(struct dprc_endpoint));
- sprintf(dpni_endpoint.type, "dpni");
+ strcpy(dpni_endpoint.type, "dpni");
dpni_endpoint.id = dflt_dpni->dpni_id;
err = dprc_connect(dflt_mc_io, MC_CMD_NO_FLAGS,
diff --git a/drivers/net/lpc32xx_eth.c b/drivers/net/lpc32xx_eth.c
index 3ba5b4b..6cc273c 100644
--- a/drivers/net/lpc32xx_eth.c
+++ b/drivers/net/lpc32xx_eth.c
@@ -582,7 +582,7 @@
}
bus->read = lpc32xx_eth_phy_read;
bus->write = lpc32xx_eth_phy_write;
- sprintf(bus->name, dev->name);
+ strcpy(bus->name, dev->name);
ret = mdio_register(bus);
if (ret) {
diff --git a/drivers/net/mpc512x_fec.c b/drivers/net/mpc512x_fec.c
index 22ea114..e850672 100644
--- a/drivers/net/mpc512x_fec.c
+++ b/drivers/net/mpc512x_fec.c
@@ -635,7 +635,7 @@
dev->send = mpc512x_fec_send;
dev->recv = mpc512x_fec_recv;
- sprintf (dev->name, "FEC");
+ strcpy(dev->name, "FEC");
eth_register (dev);
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
diff --git a/drivers/net/mpc5xxx_fec.c b/drivers/net/mpc5xxx_fec.c
index 2ebd176..e13b4cf 100644
--- a/drivers/net/mpc5xxx_fec.c
+++ b/drivers/net/mpc5xxx_fec.c
@@ -913,7 +913,7 @@
dev->send = mpc5xxx_fec_send;
dev->recv = mpc5xxx_fec_recv;
- sprintf(dev->name, "FEC");
+ strcpy(dev->name, "FEC");
eth_register(dev);
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c
index ab5aa68..b16be92 100644
--- a/drivers/net/mvgbe.c
+++ b/drivers/net/mvgbe.c
@@ -675,7 +675,7 @@
}
bus->read = mvgbe_phy_read;
bus->write = mvgbe_phy_write;
- sprintf(bus->name, dev->name);
+ strcpy(bus->name, dev->name);
ret = mdio_register(bus);
if (ret) {
diff --git a/drivers/net/ne2000_base.c b/drivers/net/ne2000_base.c
index 07a7cec..887cfd9 100644
--- a/drivers/net/ne2000_base.c
+++ b/drivers/net/ne2000_base.c
@@ -794,7 +794,7 @@
dev->send = ne2k_send;
dev->recv = ne2k_recv;
- sprintf(dev->name, "NE2000");
+ strcpy(dev->name, "NE2000");
return eth_register(dev);
}
diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c
index 1b4dd56..56d29d4 100644
--- a/drivers/net/pch_gbe.c
+++ b/drivers/net/pch_gbe.c
@@ -386,7 +386,7 @@
bus->read = pch_gbe_mdio_read;
bus->write = pch_gbe_mdio_write;
- sprintf(bus->name, name);
+ strcpy(bus->name, name);
bus->priv = (void *)mac_regs;
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index a320b4d..443a4da 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -560,7 +560,7 @@
dev->recv = sh_eth_recv;
eth->port_info[eth->port].dev = dev;
- sprintf(dev->name, SHETHER_NAME);
+ strcpy(dev->name, SHETHER_NAME);
/* Register Device to EtherNet subsystem */
eth_register(dev);
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 4bdc188..9b09caf 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -632,7 +632,7 @@
priv->phyaddr = tsec_info->phyaddr;
priv->flags = tsec_info->flags;
- sprintf(dev->name, tsec_info->devname);
+ strcpy(dev->name, tsec_info->devname);
priv->interface = tsec_info->interface;
priv->bus = miiphy_get_dev_by_name(tsec_info->mii_devname);
dev->iobase = 0;
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 20b6c18..87e54eb 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -477,7 +477,7 @@
req->complete = rx_handler_command;
req->length = EP_BUFFER_SIZE;
- sprintf(response, "OKAY");
+ strcpy(response, "OKAY");
fastboot_tx_write_str(response);
printf("\ndownloading of %d bytes finished\n", download_bytes);
@@ -506,10 +506,10 @@
printf("Starting download of %d bytes\n", download_size);
if (0 == download_size) {
- sprintf(response, "FAILdata invalid size");
+ strcpy(response, "FAILdata invalid size");
} else if (download_size > CONFIG_FASTBOOT_BUF_SIZE) {
download_size = 0;
- sprintf(response, "FAILdata too large");
+ strcpy(response, "FAILdata too large");
} else {
sprintf(response, "DATA%08x", download_size);
req->complete = rx_handler_dl_image;