NetBSD Problem Report #59946

From www@netbsd.org  Mon Jan 26 14:39:35 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.netbsd.org", Issuer "R13" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id C72171A923D
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 26 Jan 2026 14:39:35 +0000 (UTC)
Message-Id: <20260126143934.AEBC71A923E@mollari.NetBSD.org>
Date: Mon, 26 Jan 2026 14:39:34 +0000 (UTC)
From: cornina@vinschen.de
Reply-To: cornina@vinschen.de
To: gnats-bugs@NetBSD.org
Subject: gencat: handling of \<oct> expressions broken
X-Send-Pr-Version: www-1.0
X-From4GNATS: "cornina@vinschen.de via gnats" <gnats-admin@NetBSD.org>

>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
>Last-Modified:  Mon Jan 26 15:45:01 +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>
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 ---

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59946 CVS commit: src/usr.bin/gencat
Date: Mon, 26 Jan 2026 10:40:33 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Mon Jan 26 15:40:33 UTC 2026

 Modified Files:
 	src/usr.bin/gencat: gencat.c

 Log Message:
 Pr/59946: Corinna Vinschen: Octal parsing fails to advance pointer.


 To generate a diff of this commit:
 cvs rdiff -u -r1.36 -r1.37 src/usr.bin/gencat/gencat.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.