sms@etn-wlv.eaton.com (Steven M. Schultz) (04/06/89)
Description: 'mkstr' incorrectly processes octal numbers in strings. Characters of the form \ooo where 'o' is an octal digit possibly result in a truncated string (if the first digit is 0) AND definitely result in an incorrect value if more than one digit is present. Repeat-By: Run 'mkstr' on a file having a string of the form "foo\001bar". Note that only "foo\0" makes it to the output. Guess "0" wasn't considered an octal digit at some point in the past ;-) Run 'mkstr' on a file having a string of the form "foo\13", note that "foo\203" is the result. This is a result of shifting by 7 instead of three in the conversion process. Fix: Apply the following patch to mkstr.c, the extra assign of -1 to ch wasn't needed anyway. *** mkstr.c.old Wed Apr 5 21:20:30 1989 --- mkstr.c Wed Apr 5 21:27:03 1989 *************** *** 164,172 **** case 'f': c = '\f'; break; - case '0': - c = 0; - break; case '\\': break; default: --- 164,169 ---- *************** *** 176,186 **** ch = getchar(); if (!octdigit(ch)) break; ! c <<= 7, c += ch - '0'; ch = getchar(); if (!octdigit(ch)) break; ! c <<= 3, c+= ch - '0', ch = -1; break; } } --- 173,183 ---- ch = getchar(); if (!octdigit(ch)) break; ! c <<= 3, c += ch - '0'; ch = getchar(); if (!octdigit(ch)) break; ! c <<= 3, c += ch - '0'; break; } }