tr(1) attempts to convert \n[n][n] sequences into octal digits, but doesn't

check to see that a given digit is actually an octal digit.  This leads to
unusual consequences if passed in values like \9.

Reported by:	Joseph Davison (OpenDarwin project)
MFC after:	1 week
This commit is contained in:
Jordan K. Hubbard 2004-11-14 05:15:25 +00:00
parent 10695f3acb
commit 03afb27c83
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=137685

View File

@ -358,7 +358,7 @@ backslash(STR *s, int *is_octal)
*is_octal = 0;
for (cnt = val = 0;;) {
ch = (u_char)*++s->str;
if (!isdigit(ch))
if (!isdigit(ch) || ch > '7')
break;
val = val * 8 + ch - '0';
if (++cnt == 3) {