From 588a1ff7ca9a634a611c975ff114fdc8c112fc02 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 9 Jul 2020 22:59:45 +0100 Subject: [PATCH] Fix spurious warning output in KIA (-R) database file The ksh -R option creates a cross-reference database that can be parsed with a "C Query Language" (CQL) tool. See cql-1994.pdf at: http://gsf.cococlyde.org/files The -R option puts ksh in noexec mode as it parses the script, and this can produce warnings as the syntax is parsed. The bug is that these warnings can end up in the database file, corrupting it. This applies a fix from Paulo Andrade, via Siteshwar Vashisht: https://www.mail-archive.com/ast-developers@lists.research.att.com/msg01952.html src/cmd/ksh93/sh/parse.c: - Terminate names with a zero character when writing database output. A regression test is not very feasible because the majority of the database output consists of cryptic IDs/hashes that vary depending on the session and/or system and possibly other things. --- NEWS | 3 +++ src/cmd/ksh93/sh/parse.c | 1 + 2 files changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 7d26efbf8..d39f632c3 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,9 @@ Any uppercase BUG_* names are modernish shell bug IDs. - Combining ((...)) with redirections no longer causes a syntax error due to the parser handling '>' incorrectly. +- Fixed a bug that corrupted KIA/CQL cross-reference databases created using + ksh's -R option; shell warnings were wrongly included in the database file. + 2020-07-07: - Four of the date formats accepted by 'printf %()T' have had their diff --git a/src/cmd/ksh93/sh/parse.c b/src/cmd/ksh93/sh/parse.c index e14e4a8ff..047808bb3 100644 --- a/src/cmd/ksh93/sh/parse.c +++ b/src/cmd/ksh93/sh/parse.c @@ -2038,6 +2038,7 @@ unsigned long kiaentity(Lex_t *lexp,const char *name,int len,int type,int first, else sfputr(stkp,name,0); } + sfputc(stkp,'\0'); np = nv_search(stakptr(offset),lexp->entity_tree,NV_ADD); stkseek(stkp,offset); np->nvalue.i = pkind;