NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/59946: gencat: handling of \<oct> expressions broken
>Number: 59946
>Category: bin
>Synopsis: gencat: handling of \<oct> expressions broken
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jan 26 14:40:00 +0000 2026
>Originator: Corinna Vinschen
>Release: still present bug in all gencat versions since at least gencat 1.18
>Organization:
>Environment:
Not in NetBSD per se, but in Cygwin, which uses NetBSD's gencat.c verbatim
>Description:
tcsh has the following language-specific catalog file "set15" for
the C locale:
$ sh.func.c
$set 15
1 %s: %s: Can't %s%s limit (%s)\n
2 remove
3 set
4 \040hard
The problem occurs in the line starting with number 4.
\040 represents a space. When running this through gencat, the
catalog file contains the string "hard" instead of the expected
" hard" with leading space.
Debugging this issue turns up the cause:
After the loop creating the correct target character in *tptr,
the code neglects to increment tptr. The result is that tptr
still points to the just created space when the 'h' comes along,
so the character created from the \<oct> expression is just
overwriotten by the next character of the source string.
>How-To-Repeat:
Just cd to a tcsh source dir and run
gencat C.cat C/charset C/set15
install and start tcsh and then run the following as unprivileged
user:
$ limit -h maxproc 3000
$ limit -h maxproc 3001
limit: maxproc: Can't sethard limit
Observe the missing space between "set" and "hard".
>Fix:
Here's a git patchfile against current trunk
--- SNIP ---
>From 4b01c91c11632e0b39ab3b97d5a60f6fca9bdfcd Mon Sep 17 00:00:00 2001
From: Corinna Vinschen <corinna%vinschen.de@localhost>
Date: Mon, 26 Jan 2026 15:22:29 +0100
Subject: [PATCH] gencat: fix handling of \<oct> expressions
The code handling \<oct> expressions (backslash with 3 octal digits)
neglects to increment the pointer to the target string afterwards,
thus the next character simply overwrites the character created from
the \<oct> expression. Fix that.
---
usr.bin/gencat/gencat.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/usr.bin/gencat/gencat.c b/usr.bin/gencat/gencat.c
index 444ce2d43e88..77d31ae276f2 100644
--- a/usr.bin/gencat/gencat.c
+++ b/usr.bin/gencat/gencat.c
@@ -444,6 +444,7 @@ getmsg(int fd, char *cptr, char quote)
*tptr += (*cptr - '0');
++cptr;
}
+ ++tptr;
} else {
warning(cptr, "unrecognized escape sequence");
}
--
2.52.0
--- SNAP ---
Home |
Main Index |
Thread Index |
Old Index