Sorry for wrong indents. Patch in attachment.

RR
diff -up bash-4.1/builtins/printf.def.octal bash-4.1/builtins/printf.def
--- bash-4.1/builtins/printf.def.octal  2010-12-07 15:40:24.000000000 +0100
+++ bash-4.1/builtins/printf.def        2010-12-07 16:13:41.000000000 +0100
@@ -734,11 +734,15 @@ tescape (estart, cp, sawc)
 
       /* The octal escape sequences are `\0' followed by up to three octal
         digits (if SAWC), or `\' followed by up to three octal digits (if
-        !SAWC).  As an extension, we allow the latter form even if SAWC. */
+        !SAWC).  As an extension, we allow the latter form even if SAWC.
+         If the octal character begins with number 4 or higher,
+         only 2 octal digits fit to byte */
       case '0': case '1': case '2': case '3':
       case '4': case '5': case '6': case '7':
        evalue = OCTVALUE (c);
-       for (temp = 2 + (!evalue && !!sawc); ISOCTAL (*p) && temp--; p++)
+       for (temp = 2 + (!evalue && !!sawc) -
+             (!sawc ? c > '3' : evalue ? evalue > 3 : *p > '3');
+             ISOCTAL (*p) && temp--; p++)
          evalue = (evalue * 8) + OCTVALUE (*p);
        *cp = evalue & 0xFF;
        break;
diff -up bash-4.1/lib/sh/strtrans.c.octal bash-4.1/lib/sh/strtrans.c
--- bash-4.1/lib/sh/strtrans.c.octal    2008-08-12 19:49:12.000000000 +0200
+++ bash-4.1/lib/sh/strtrans.c  2010-12-07 15:40:24.000000000 +0100
@@ -96,6 +96,8 @@ ansicstr (string, len, flags, sawc, rlen
                 POSIX-2001 requirement and accept 0-3 octal digits after
                 a leading `0'. */
              temp = 2 + ((flags & 1) && (c == '0'));
+              if (*s > '3')
+                temp--;
              for (c -= '0'; ISOCTAL (*s) && temp--; s++)
                c = (c * 8) + OCTVALUE (*s);
              c &= 0xFF;

Reply via email to