svn commit: r363540 - in head/sys/geom: . part virstor

Xin LI delphij at FreeBSD.org
Sun Jul 26 01:45:27 UTC 2020


Author: delphij
Date: Sun Jul 26 01:45:26 2020
New Revision: 363540
URL: https://svnweb.freebsd.org/changeset/base/363540

Log:
  Use snprintf instead of sprintf.
  
  MFC after:	2 weeks

Modified:
  head/sys/geom/geom_ccd.c
  head/sys/geom/part/g_part_vtoc8.c
  head/sys/geom/virstor/g_virstor.c

Modified: head/sys/geom/geom_ccd.c
==============================================================================
--- head/sys/geom/geom_ccd.c	Sun Jul 26 01:11:30 2020	(r363539)
+++ head/sys/geom/geom_ccd.c	Sun Jul 26 01:45:26 2020	(r363540)
@@ -771,7 +771,7 @@ g_ccd_create(struct gctl_req *req, struct g_class *mp)
 
 	/* Check all providers are valid */
 	for (i = 0; i < *nprovider; i++) {
-		sprintf(buf, "provider%d", i);
+		snprintf(buf, sizeof(buf), "provider%d", i);
 		pp = gctl_get_provider(req, buf);
 		if (pp == NULL)
 			return;
@@ -788,7 +788,7 @@ g_ccd_create(struct gctl_req *req, struct g_class *mp)
 
 	/* Create consumers and attach to all providers */
 	for (i = 0; i < *nprovider; i++) {
-		sprintf(buf, "provider%d", i);
+		snprintf(buf, sizeof(buf), "provider%d", i);
 		pp = gctl_get_provider(req, buf);
 		cp = g_new_consumer(gp);
 		error = g_attach(cp, pp);

Modified: head/sys/geom/part/g_part_vtoc8.c
==============================================================================
--- head/sys/geom/part/g_part_vtoc8.c	Sun Jul 26 01:11:30 2020	(r363539)
+++ head/sys/geom/part/g_part_vtoc8.c	Sun Jul 26 01:45:26 2020	(r363540)
@@ -224,7 +224,8 @@ g_part_vtoc8_create(struct g_part_table *basetable, st
 	ncyls = pcyls - acyls;
 	msize = ncyls * table->secpercyl;
 
-	sprintf(table->vtoc.ascii, "FreeBSD%lldM cyl %u alt %u hd %u sec %u",
+	snprintf(table->vtoc.ascii, sizeof(table->vtoc.ascii),
+	    "FreeBSD%lldM cyl %u alt %u hd %u sec %u",
 	    (long long)(msize / 2048), ncyls, acyls, basetable->gpt_heads,
 	    basetable->gpt_sectors);
 	be32enc(&table->vtoc.version, VTOC_VERSION);
@@ -338,7 +339,8 @@ vtoc8_set_rawsize(struct g_part_table *basetable, stru
 	basetable->gpt_last = msize - 1;
 
 	bzero(table->vtoc.ascii, sizeof(table->vtoc.ascii));
-	sprintf(table->vtoc.ascii, "FreeBSD%lldM cyl %u alt %u hd %u sec %u",
+	snprintf(table->vtoc.ascii, sizeof(table->vtoc.ascii),
+	    "FreeBSD%lldM cyl %u alt %u hd %u sec %u",
 	    (long long)(msize / 2048), ncyls, acyls, basetable->gpt_heads,
 	    basetable->gpt_sectors);
 	be16enc(&table->vtoc.physcyls, pcyls);

Modified: head/sys/geom/virstor/g_virstor.c
==============================================================================
--- head/sys/geom/virstor/g_virstor.c	Sun Jul 26 01:11:30 2020	(r363539)
+++ head/sys/geom/virstor/g_virstor.c	Sun Jul 26 01:45:26 2020	(r363540)
@@ -227,7 +227,7 @@ virstor_ctl_stop(struct gctl_req *req, struct g_class 
 		struct g_virstor_softc *sc;
 		int error;
 
-		sprintf(param, "arg%d", i);
+		snprintf(param, sizeof(param), "arg%d", i);
 		name = gctl_get_asciiparam(req, param);
 		if (name == NULL) {
 			gctl_error(req, "No 'arg%d' argument", i);
@@ -565,7 +565,7 @@ virstor_ctl_remove(struct gctl_req *req, struct g_clas
 		int j, found;
 		struct g_virstor_component *newcomp, *compbak;
 
-		sprintf(param, "arg%d", i);
+		snprintf(param, sizeof(param), "arg%d", i);
 		prov_name = gctl_get_asciiparam(req, param);
 		if (prov_name == NULL) {
 			gctl_error(req, "Error fetching argument '%s'", param);


More information about the svn-src-all mailing list