summaryrefslogtreecommitdiff
blob: 760e4ad5620958fc0b591f74faa8d02dae0ec95f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
http://bugs.gentoo.org/337329

do not interpret \\1 as an octal sequence.  require it to start with \\0.

--- a/src/bltin/printf.c
+++ b/src/bltin/printf.c
@@ -247,18 +247,10 @@ conv_escape_str(char *str)
 		 * They start with a \0, and are followed by 0, 1, 2, 
 		 * or 3 octal digits. 
 		 */
-		if (ch == '0') {
-			unsigned char i;
-			i = 3;
-			ch = 0;
-			do {
-				unsigned k = octtobin(*str);
-				if (k > 7)
-					break;
-				str++;
-				ch <<= 3;
-				ch += k;
-			} while (--i);
+		if (ch >= '1' && ch <= '9') {
+			/* Filter \1...\9; let \0 fall to conv_escape(). */
+			ch = '\\';
+			--str;
 			continue;
 		}