O.o, whhops, that was the wrong patch, attached is the correct one.
sorry for spamming the list.
diff --git a/ed.c b/ed.c
index 184ed30..feeab43 100644
--- a/ed.c
+++ b/ed.c
@@ -316,7 +316,7 @@ inject(char *s)
 }
 
 static void
-clearbuf()
+clearbuf(void)
 {
 	if (scratch)
 		close(scratch);
@@ -328,7 +328,7 @@ clearbuf()
 }
 
 static void
-setscratch()
+setscratch(void)
 {
 	int r, k;
 	char *dir;
@@ -407,7 +407,7 @@ match(int num)
 }
 
 static int
-rematch(int num)
+rematch(void)
 {
 	regoff_t off = matchs[0].rm_eo;
 
@@ -451,18 +451,14 @@ getnum(void)
 
 	for (ln = 0; isdigit(c = input()); ln += n) {
 		if (ln > INT_MAX/10)
-			goto invalid;
+			error("invalid address");
 		n = c - '0';
 		ln *= 10;
 		if (INT_MAX - ln < n)
-			goto invalid;
+			error("invalid address");
 	}
 	back(c);
 	return ln;
-
-invalid:
-	error("invalid address");
-	return -1; /* not reached */
 }
 
 static int
@@ -525,7 +521,7 @@ address(int *line)
 		num = isdigit(back(input())) ? getnum() : 1;
 		num *= sign;
 		if (INT_MAX - ln < num)
-			goto invalid;
+			error("invalid address");
 		ln += num;
 	}
 	back(c);
@@ -534,14 +530,10 @@ address(int *line)
 		error("invalid address");
 	*line = ln;
 	return 1;
-
-invalid:
-	error("invalid address");
-	return -1; /* not reached */
 }
 
 static void
-getlst()
+getlst(void)
 {
 	int ln, c;
 
@@ -589,7 +581,7 @@ deflines(int def1, int def2)
 }
 
 static void
-dowrite(char *fname, int trunc)
+dowrite(const char *fname, int trunc)
 {
 	FILE *fp;
 	int i, line;
@@ -604,13 +596,14 @@ dowrite(char *fname, int trunc)
 	curln = line2;
 	if (fclose(fp))
 		error("input/output error");
-	strcpy(savfname, fname);
+	if (strlcpy(savfname, fname, sizeof(savfname)) >= sizeof(savfname))
+		error("file name too long");
 	modflag = 0;
 	curln = line;
 }
 
 static void
-doread(char *fname)
+doread(const char *fname)
 {
 	size_t cnt;
 	ssize_t n;
@@ -734,8 +727,10 @@ getfname(char comm)
 		error("file name too long");
 	} else {
 		*bp = '\0';
-		if (savfname[0] == '\0' || comm == 'e' || comm == 'f')
-			strcpy(savfname, fname);
+		if (savfname[0] == '\0' || comm == 'e' || comm == 'f') {
+			if (strlcpy(savfname, fname, sizeof(savfname)) >= sizeof(savfname))
+				error("file name too long");
+		}
 		return fname;
 	}
 	return NULL; /* not reached */
@@ -1010,7 +1005,7 @@ subline(int num, int nth)
 	static size_t siz, cap;
 
 	i = changed = siz = 0;
-	for (m = match(num); m; m = rematch(num)) {
+	for (m = match(num); m; m = rematch()) {
 		addpre(&s, &cap, &siz);
 		changed |= addsub(&s, &cap, &siz, nth, ++i);
 		if (eol || bol)

Reply via email to