Module Name:    src
Committed By:   dholland
Date:           Mon May 25 23:14:33 UTC 2009

Modified Files:
        src/games/phantasia: main.c misc.c

Log Message:
sprintf -> snprintf


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/games/phantasia/main.c
cvs rdiff -u -r1.16 -r1.17 src/games/phantasia/misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/phantasia/main.c
diff -u src/games/phantasia/main.c:1.18 src/games/phantasia/main.c:1.19
--- src/games/phantasia/main.c:1.18	Mon May 25 23:08:45 2009
+++ src/games/phantasia/main.c	Mon May 25 23:14:33 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.18 2009/05/25 23:08:45 dholland Exp $	*/
+/*	$NetBSD: main.c,v 1.19 2009/05/25 23:14:33 dholland Exp $	*/
 
 /*
  * Phantasia 3.3.2 -- Interterminal fantasy game
@@ -647,7 +647,8 @@
 		    Other.p_status != S_NOTUSED)
 			/* found the king */
 		{
-			sprintf(Databuf, "The present ruler is %s  Level:%.0f",
+			snprintf(Databuf, SZ_DATABUF,
+			    "The present ruler is %s  Level:%.0f",
 			    Other.p_name, Other.p_level);
 			mvaddstr(4, 40 - strlen(Databuf) / 2, Databuf);
 			kingfound = TRUE;
@@ -662,7 +663,9 @@
 		if (Other.p_specialtype == SC_VALAR && Other.p_status != S_NOTUSED)
 			/* found the valar */
 		{
-			sprintf(Databuf, "The Valar is %s   Login:  %s", Other.p_name, Other.p_login);
+			snprintf(Databuf, SZ_DATABUF,
+				"The Valar is %s   Login:  %s",
+				Other.p_name, Other.p_login);
 			mvaddstr(6, 40 - strlen(Databuf) / 2, Databuf);
 			break;
 		}
@@ -678,7 +681,8 @@
 				councilfound = TRUE;
 			}
 			/* This assumes a finite (<=5) number of C.O.W.: */
-			sprintf(Databuf, "%s   Login:  %s", Other.p_name, Other.p_login);
+			snprintf(Databuf, SZ_DATABUF,
+				"%s   Login:  %s", Other.p_name, Other.p_login);
 			mvaddstr(Lines++, 40 - strlen(Databuf) / 2, Databuf);
 		}
 	/* search for the two highest players */
@@ -708,7 +712,8 @@
 				strcpy(nxtname, Other.p_name);
 			}
 	mvaddstr(15, 28, "Highest characters are:");
-	sprintf(Databuf, "%s  Level:%.0f   and   %s  Level:%.0f",
+	snprintf(Databuf, SZ_DATABUF,
+	    "%s  Level:%.0f   and   %s  Level:%.0f",
 	    hiname, hilvl, nxtname, nxtlvl);
 	mvaddstr(17, 40 - strlen(Databuf) / 2, Databuf);
 

Index: src/games/phantasia/misc.c
diff -u src/games/phantasia/misc.c:1.16 src/games/phantasia/misc.c:1.17
--- src/games/phantasia/misc.c:1.16	Mon May 25 23:08:45 2009
+++ src/games/phantasia/misc.c	Mon May 25 23:14:33 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: misc.c,v 1.16 2009/05/25 23:08:45 dholland Exp $	*/
+/*	$NetBSD: misc.c,v 1.17 2009/05/25 23:14:33 dholland Exp $	*/
 
 /*
  * misc.c  Phantasia miscellaneous support routines
@@ -133,9 +133,11 @@
 							}
 
 	if (shortflag)
-		sprintf(Databuf, "%.29s", label);
+		snprintf(Databuf, SZ_DATABUF, "%.29s", label);
 	else
-		sprintf(Databuf, " is in %s  (%.0f,%.0f)", label, playerp->p_x, playerp->p_y);
+		snprintf(Databuf, SZ_DATABUF, 
+			" is in %s  (%.0f,%.0f)",
+			label, playerp->p_x, playerp->p_y);
 
 	return (Databuf);
 }

Reply via email to