$NetBSD: patch-ai,v 1.6 2007/01/06 22:45:49 wiz Exp $

--- src/display.c.orig	2006-09-30 08:13:00.000000000 +0000
+++ src/display.c
@@ -478,21 +478,25 @@ search(void)
 	/* see if it is empty */
 	if ((c = getc(refsfound)) == EOF) {
 		if (findresult != NULL) {
-			(void) sprintf(lastmsg, "Egrep %s in this pattern: %s", 
-				       findresult, Pattern);
-		} else if (rc == NOTSYMBOL) {
-			(void) sprintf(lastmsg, "This is not a C symbol: %s", 
-				       Pattern);
-		} else if (rc == REGCMPERROR) {
-			(void) sprintf(lastmsg, "Error in this regcomp(3) regular expression: %s", 
-				       Pattern);
+			(void) snprintf(lastmsg, sizeof(lastmsg), "Egrep %s in this pattern: %s", 
+				findresult, Pattern);
+		}
+		else if (rc == NOTSYMBOL) {
+			(void) snprintf(lastmsg, sizeof(lastmsg), "This is not a C symbol: %s", 
+				Pattern);
+		}
+		else if (rc == REGCMPERROR) {
+			(void) snprintf(lastmsg, sizeof(lastmsg), "Error in this regcomp(3) regular expression: %s", 
+				Pattern);
 			
-		} else if (funcexist == NO) {
-			(void) sprintf(lastmsg, "Function definition does not exist: %s", 
-				       Pattern);
-		} else {
-			(void) sprintf(lastmsg, "Could not find the %s: %s", 
-				       fields[field].text2, Pattern);
+		}
+		else if (funcexist == NO) {
+			(void) snprintf(lastmsg, sizeof(lastmsg), "Function definition does not exist: %s", 
+				Pattern);
+		}
+		else {
+			(void) snprintf(lastmsg, sizeof(lastmsg), "Could not find the %s: %s", 
+				fields[field].text2, Pattern);
 		}
 		return(NO);
 	}
@@ -527,17 +531,17 @@ progress(char *what, long current, long 
 			move(MSGLINE, 0);
 			clrtoeol();
 			addstr(what);
-			sprintf(msg, "%ld", current);
+			snprintf(msg, sizeof(msg), "%ld", current);
 			move(MSGLINE, (COLS / 2) - (strlen(msg) / 2));
 			addstr(msg);
-			sprintf(msg, "%ld", max);
+			snprintf(msg, sizeof(msg), "%ld", max);
 			move(MSGLINE, COLS - strlen(msg));
 			addstr(msg);
 			refresh();
 		}
 		else if (verbosemode == YES)
 		{
-			sprintf(msg, "> %s %ld of %ld", what, current, max);
+			snprintf(msg, sizeof(msg), "> %s %ld of %ld", what, current, max);
 		}
 
 		start = now;
@@ -575,7 +579,7 @@ myperror(char *text) 
 		s = sys_errlist[errno];
 	}
 #endif
-	(void) sprintf(msg, "%s: %s", text, s);
+	(void) snprintf(msg, sizeof(msg), "%s: %s", text, s);
 	postmsg(msg);
 }
 
