[hackers] [sbase] [PATCH 2/3] ed: Fix backslash expressions in RHS

From: Wolfgang Corcoran-Mathe <wcm_AT_sigwinch.xyz>
Date: Sun, 24 Jul 2016 21:04:28 -0400

By stripping backslashes this code caused a number of bugs.
'\<digit>' expressions caused literal <digit>s to be subbed-in,
'\&' was treated identically to '&', and other escaped characters
added garbage to the string.
---
 ed.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/ed.c b/ed.c
index e41fbdd..ae9e6d7 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -900,13 +900,8 @@ getrhs(int delim)
 	free(s);
 	s = NULL;
 	siz = cap = 0;
-	while ((c = input()) != '\n' && c != EOF && c != delim) {
-		if (c == '\\') {
-			if ((c = input()) == '&' || isdigit(c))
-				s = addchar(c, s, &siz, &cap);
-		}
+	while ((c = input()) != '\n' && c != EOF && c != delim)
 		s = addchar(c, s, &siz, &cap);
-	}
 	s = addchar('\0', s, &siz, &cap);
 	if (c == EOF)
 		error("invalid pattern delimiter");
-- 
2.9.0
Received on Mon Jul 25 2016 - 03:04:28 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 25 2016 - 03:12:18 CEST