summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-11-06 09:04:50 +0000
committerJim Meyering <jim@meyering.net>2002-11-06 09:04:50 +0000
commit0a5d4112ba0a031583ed67deb51aea6b402d24b4 (patch)
tree846bf3b9ce5331e1ec208c3d261ad85d0fcf2f6d /src
parent1f5b4821240bfb931292514d9da649eab05fa753 (diff)
downloadcoreutils-0a5d4112ba0a031583ed67deb51aea6b402d24b4.tar.xz
(print_esc): Hexadecimal \xhh escapes may have
at most two hex. digits, not three.
Diffstat (limited to 'src')
-rw-r--r--src/printf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/printf.c b/src/printf.c
index f8fb51065..26accf237 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -240,11 +240,11 @@ print_esc (const char *escstart)
int esc_value = 0; /* Value of \nnn escape. */
int esc_length; /* Length of \nnn escape. */
- /* \0ooo and \xhhh escapes have maximum length of 3 chars. */
if (*p == 'x')
{
+ /* A hexadecimal \xhh escape sequence must have 1 or 2 hex. digits. */
for (esc_length = 0, ++p;
- esc_length < 3 && ISXDIGIT (*p);
+ esc_length < 2 && ISXDIGIT (*p);
++esc_length, ++p)
esc_value = esc_value * 16 + hextobin (*p);
if (esc_length == 0)
@@ -253,6 +253,8 @@ print_esc (const char *escstart)
}
else if (*p == '0')
{
+ /* An octal \0ooo escape sequence has 0 to 3 octal digits
+ after the leading \0. */
for (esc_length = 0, ++p;
esc_length < 3 && isodigit (*p);
++esc_length, ++p)