diff options
author | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2021-10-31 21:34:17 +0000 |
---|---|---|
committer | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2021-10-31 21:34:17 +0000 |
commit | dfed0fbc5b65fbc8656999c8812099e0ce4bd5cc (patch) | |
tree | 6f50f08bc4bc60d512081b2b4f10b29349bcb946 /usr.bin/tmux/cmd-rename-window.c | |
parent | 6939737ddd1c9390c190631e43a893f7ba8bf563 (diff) |
tr(1): backslash(): fix octal escape parsing
There are two bugs in backslash():
1. 8 and 9 are not octal digits. If we see '8' or '9' we should
terminate the octal escape.
2. We return octal escape values larger than UCHAR_MAX even though
tr(1) is (currently) a byte-oriented program and values larger
than UCHAR_MAX make no sense.
So, fix them both. In particular, (a) stop parsing if we see
characters outside of '0'-'7' and (b) escaped octal values larger than
UCHAR_MAX are a terminal error.
While here, some cleanup:
- Check for empty escapes at the top of the function. This simplifies
later cases.
- Use the for-loop conditional to terminate octal escape parsing after
three characters.
- Use an ANSI-style function definition.
We can fix the switch-statement indentation later, in a larger KNF
patch.
ok millert@
Diffstat (limited to 'usr.bin/tmux/cmd-rename-window.c')
0 files changed, 0 insertions, 0 deletions