From 3c7c02a5f7ba0e1704fdf3b6792b0a5ab6d1756a Mon Sep 17 00:00:00 2001 From: kim Date: Thu, 18 Nov 2021 10:20:47 +0000 Subject: [PATCH] {,standalone-,static-}tcsh: Pull in some additional patches - Fix off-by-one, found by Coverity - Don't glob the filetest builtin arguments twice - Add more detail to "jobs -Z" usage --- shells/standalone-tcsh/Makefile | 4 +-- shells/static-tcsh/Makefile | 4 +-- shells/tcsh/Makefile | 4 +-- shells/tcsh/distinfo | 10 +++++--- shells/tcsh/patches/patch-sh.exp.c | 32 +++++++++++++++++++++++ shells/tcsh/patches/patch-sh.func.c | 18 +++++++++++++ shells/tcsh/patches/patch-sh.h | 22 +++++++++++++--- shells/tcsh/patches/patch-tcsh.man | 38 +++++++++++++++++++++++++--- shells/tcsh/patches/patch-tw.color.c | 16 ++++++++---- 9 files changed, 125 insertions(+), 23 deletions(-) create mode 100644 shells/tcsh/patches/patch-sh.exp.c create mode 100644 shells/tcsh/patches/patch-sh.func.c diff --git a/shells/standalone-tcsh/Makefile b/shells/standalone-tcsh/Makefile index 8d5f714d0696..a70b8dd86041 100644 --- a/shells/standalone-tcsh/Makefile +++ b/shells/standalone-tcsh/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.36 2021/11/15 19:54:11 kim Exp $ +# $NetBSD: Makefile,v 1.37 2021/11/18 10:20:47 kim Exp $ # # FIXME: This is because of PREFIX=/ below. @@ -6,7 +6,7 @@ CHECK_FILES_SUPPORTED= no NOT_FOR_UNPRIVILEGED= yes PKGNAME= standalone-${DISTNAME} -PKGREVISION= 2 +PKGREVISION= 3 PATCHDIR= ../../shells/tcsh/patches PKGDIR= ../../shells/tcsh diff --git a/shells/static-tcsh/Makefile b/shells/static-tcsh/Makefile index a2920d1bf58b..55db19be8643 100644 --- a/shells/static-tcsh/Makefile +++ b/shells/static-tcsh/Makefile @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.15 2021/11/15 19:56:03 kim Exp $ +# $NetBSD: Makefile,v 1.16 2021/11/18 10:20:47 kim Exp $ # PKGNAME= static-${DISTNAME} -PKGREVISION= 2 +PKGREVISION= 3 .include "../../shells/tcsh/Makefile.common" diff --git a/shells/tcsh/Makefile b/shells/tcsh/Makefile index ee8810182924..ac86814275b3 100644 --- a/shells/tcsh/Makefile +++ b/shells/tcsh/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.102 2021/11/15 17:11:58 kim Exp $ +# $NetBSD: Makefile,v 1.103 2021/11/18 10:20:47 kim Exp $ .include "../../shells/tcsh/Makefile.common" -PKGREVISION= 2 +PKGREVISION= 3 .include "../../mk/bsd.pkg.mk" diff --git a/shells/tcsh/distinfo b/shells/tcsh/distinfo index ac49bd07a75e..8143617d3270 100644 --- a/shells/tcsh/distinfo +++ b/shells/tcsh/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.55 2021/11/18 08:55:34 kim Exp $ +$NetBSD: distinfo,v 1.56 2021/11/18 10:20:47 kim Exp $ BLAKE2s (tcsh-6.23.00.tar.gz) = a61b142efc2ca927cb33ea4eb87c0530cacc0c79ff1c30d5e9022a4404cef72d SHA512 (tcsh-6.23.00.tar.gz) = 8ea491e9409f12ab113bf5551398cb827692a50340318b050d0f8278d3cd9c133ba89a407dc692d9c4bd69957ecd6d4d92db7ccfacc7064ace3b09e3bd562f30 @@ -6,6 +6,8 @@ Size (tcsh-6.23.00.tar.gz) = 1010250 bytes SHA1 (patch-Makefile.in) = 16ae4c595c8e23be1acbfa0263334df569300a79 SHA1 (patch-config_f.h) = 715d939e8a8f4917bd219dccd91d5c49ae502939 SHA1 (patch-nls_Makefile.in) = 58d859e8a50e6436b9bc6514497eb876426d92d7 -SHA1 (patch-sh.h) = ac6211ddd5e552e9baec2d35aed5e7e573cab04e -SHA1 (patch-tcsh.man) = 7ced0fbcc2bdae180d3e88acda44e189ca37abc6 -SHA1 (patch-tw.color.c) = 9ad72f83e6ebf21bb587cc6c83657a2b4bdee0e6 +SHA1 (patch-sh.exp.c) = c65aeedf8950d2e298d1d0a5dbe2261eba18ff77 +SHA1 (patch-sh.func.c) = f06cddb996915e79e372d56984f3798a68437e05 +SHA1 (patch-sh.h) = 487282e85cd6f21a703d7d5332c47f113ca2fea8 +SHA1 (patch-tcsh.man) = 1265cc74450170f65c282921859c3b29ef6caa39 +SHA1 (patch-tw.color.c) = 39c1f8a0821b8254c6bb4729b5e1504c6a83feb5 diff --git a/shells/tcsh/patches/patch-sh.exp.c b/shells/tcsh/patches/patch-sh.exp.c new file mode 100644 index 000000000000..d35187881145 --- /dev/null +++ b/shells/tcsh/patches/patch-sh.exp.c @@ -0,0 +1,32 @@ +$NetBSD: patch-sh.exp.c,v 1.1 2021/11/18 10:20:47 kim Exp $ + +Don't glob the filetest builtin arguments twice: + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=905649 + +https://github.com/tcsh-org/tcsh/commit/8a83d4c717ad4a56450751986b65ccd6ea9eed8a.patch + +--- sh.exp.c ++++ sh.exp.c +@@ -36,9 +36,6 @@ + * C shell + */ + +-#define TEXP_IGNORE 1 /* in ignore, it means to ignore value, just parse */ +-#define TEXP_NOGLOB 2 /* in ignore, it means not to globone */ +- + #define ADDOP 1 + #define MULOP 2 + #define EQOP 4 +@@ -677,7 +674,11 @@ filetest(Char *cp, Char ***vp, int ignore) + dp = *(*vp)++; + if (ignore & TEXP_IGNORE) + return (Strsave(STRNULL)); +- ep = globone(dp, G_APPEND); ++ if ((ignore & TEXP_NOGLOB) == 0) { ++ ep = globone(dp, G_APPEND); ++ } else { ++ ep = Strsave(dp); ++ } + cleanup_push(ep, xfree); + ft = &cp[1]; + do diff --git a/shells/tcsh/patches/patch-sh.func.c b/shells/tcsh/patches/patch-sh.func.c new file mode 100644 index 000000000000..837f79a85bfd --- /dev/null +++ b/shells/tcsh/patches/patch-sh.func.c @@ -0,0 +1,18 @@ +$NetBSD: patch-sh.func.c,v 1.3 2021/11/18 10:20:47 kim Exp $ + +Don't glob the filetest builtin arguments twice: + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=905649 + +https://github.com/tcsh-org/tcsh/commit/8a83d4c717ad4a56450751986b65ccd6ea9eed8a.patch + +--- sh.func.c ++++ sh.func.c +@@ -227,7 +227,7 @@ dofiletest(Char **v, struct command *c) + cleanup_push(globbed, blk_cleanup); + + while (*(fileptr = v++) != NULL) { +- res = filetest(ftest, &fileptr, 0); ++ res = filetest(ftest, &fileptr, TEXP_NOGLOB); + cleanup_push(res, xfree); + xprintf("%S", res); + cleanup_until(res); diff --git a/shells/tcsh/patches/patch-sh.h b/shells/tcsh/patches/patch-sh.h index 38dc6a5a080f..4180c66246b4 100644 --- a/shells/tcsh/patches/patch-sh.h +++ b/shells/tcsh/patches/patch-sh.h @@ -1,10 +1,15 @@ -$NetBSD: patch-sh.h,v 1.1 2014/05/25 03:59:17 rodent Exp $ +$NetBSD: patch-sh.h,v 1.2 2021/11/18 10:20:47 kim Exp $ Add OpenBSD support. ---- sh.h.orig 2011-04-14 18:25:25.000000000 +0000 -+++ sh.h -@@ -310,7 +310,7 @@ typedef long tcsh_number_t; +Don't glob the filetest builtin arguments twice: + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=905649 + +https://github.com/tcsh-org/tcsh/commit/8a83d4c717ad4a56450751986b65ccd6ea9eed8a.patch + +--- sh.h.orig 2021-11-11 09:54:05.000000000 +0000 ++++ sh.h 2021-11-18 10:03:48.441361892 +0000 +@@ -320,7 +320,7 @@ * redefines malloc(), so we define the following * to avoid it. */ @@ -13,3 +18,12 @@ Add OpenBSD support. # define NO_FIX_MALLOC # include # else /* glibc */ +@@ -1299,4 +1299,8 @@ + + #include "tc.nls.h" + ++#define TEXP_IGNORE 1 /* in ignore, it means to ignore value, just parse */ ++#define TEXP_NOGLOB 2 /* in ignore, it means not to globone */ ++ ++ + #endif /* _h_sh */ diff --git a/shells/tcsh/patches/patch-tcsh.man b/shells/tcsh/patches/patch-tcsh.man index 21fefabc5d41..cba4f8698b9d 100644 --- a/shells/tcsh/patches/patch-tcsh.man +++ b/shells/tcsh/patches/patch-tcsh.man @@ -1,12 +1,42 @@ -$NetBSD: patch-tcsh.man,v 1.1 2021/11/14 22:15:13 kim Exp $ +$NetBSD: patch-tcsh.man,v 1.2 2021/11/18 10:20:47 kim Exp $ Document ln=target +Add more detail to "jobs -Z" usage. https://github.com/tcsh-org/tcsh/commit/b98d6544234e9258156f08c8b559ed6253f2bc49.patch +https://github.com/tcsh-org/tcsh/commit/a81394cfaca1b9cf4d9cf8d3f4d8c0126b8b09d0.patch ---- tcsh.man -+++ tcsh.man -@@ -5088,6 +5088,9 @@ A few terminal programs do not recognize the default end code +--- tcsh.man.orig 2021-11-11 09:54:05.000000000 +0000 ++++ tcsh.man 2021-11-18 10:08:01.436706660 +0000 +@@ -2972,16 +2972,22 @@ + .B inlib \fIshared-library\fR ... (+) + Adds each \fIshared-library\fR to the current environment. There is no way + to remove a shared library. (Domain/OS only) ++.PP ++.B jobs \fR[\fB\-l\fR] ++.PD 0 + .TP 8 +-.B jobs \fR[\fB\-lZ\fR] ++.B jobs \-Z \fR[\fItitle\fR] (+) + Lists the active jobs. With \fB\-l\fR, lists process + IDs in addition to the normal information. On TCF systems, prints + the site on which each job is executing. +-The \fB-Z\fR option sets the process title using setproctitle(3) +-where available. ++.PD ++.RS +8 ++.PP ++The \fB-Z\fR option sets the process title to \fItitle\fR using ++setproctitle(3) where available. ++If no \fItitle\fR is provided, the process title will be cleared. ++.RE + .PP +-.PD 0 +-.TP 8 + .B kill \fR[\fB\-s \fIsignal\fR] \fB%\fIjob\fR|\fIpid\fR ... + .PD 0 + .TP 8 +@@ -5088,6 +5094,9 @@ properly. If all text gets colorized after you do a directory listing, try changing the \fBno\fR and \fBfi\fR codes from 0 to the numerical codes for your standard fore- and background colors. diff --git a/shells/tcsh/patches/patch-tw.color.c b/shells/tcsh/patches/patch-tw.color.c index 49ba7ef64faf..5fb5b9ac5436 100644 --- a/shells/tcsh/patches/patch-tw.color.c +++ b/shells/tcsh/patches/patch-tw.color.c @@ -1,13 +1,19 @@ -$NetBSD: patch-tw.color.c,v 1.1 2021/11/14 22:15:13 kim Exp $ +$NetBSD: patch-tw.color.c,v 1.2 2021/11/18 10:20:47 kim Exp $ Fix the ln=target code by NUL terminating the result of readlink(2). +Fix off-by-one, found by Coverity https://github.com/tcsh-org/tcsh/commit/247a7d6649621fdc40c31ad81c4967413213b9d2.patch +https://github.com/tcsh-org/tcsh/commit/92e557e324655906b73bad5253885051bbb7162e.patch ---- tw.color.c -+++ tw.color.c -@@ -482,10 +482,12 @@ print_with_color(const Char *filename, size_t len, Char suffix) - char buf[MAXPATHLEN]; +--- tw.color.c.orig 2021-11-11 09:54:05.000000000 +0000 ++++ tw.color.c 2021-11-18 09:54:30.997940824 +0000 +@@ -479,13 +479,15 @@ + if (suffix == '@' && color_as_referent) { + char *f = short2str(filename); + Char c = suffix; +- char buf[MAXPATHLEN]; ++ char buf[MAXPATHLEN + 1]; while (c == '@') { - if (readlink(f, buf, MAXPATHLEN) == -1) {