Module Name: src Committed By: kre Date: Fri Dec 29 15:49:24 UTC 2023
Modified Files: src/bin/sh: expand.c Log Message: PR bin/57773 Fix another bug reported by Jarle Fredrik Greipsland and added to PR bin/57773, which relates to calculating the length of a positional parameter which contains CTL chars -- yes, this one really is that specific, though it would also affect the special param $0 if it were to contain CTL chars, and its length was requested - that is fixed with the same change. And note: $0 is not affected because it looks like a positional param (it isn't, ${00} would be, but is always unset, ${0} isn't) all special parame would be affected the same way, but the only one that can ever contain a CTL char is $0 I believe. ($@ and $* were affected, but just because they're expanding the positional params ... ${#@} and ${#*} are both technically unspecified expansions - and different shells produce different results. See the PR for the details of this one (and the previous). Thanks for the PR. XXX pullup to everything. To generate a diff of this commit: cvs rdiff -u -r1.143 -r1.144 src/bin/sh/expand.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/sh/expand.c diff -u src/bin/sh/expand.c:1.143 src/bin/sh/expand.c:1.144 --- src/bin/sh/expand.c:1.143 Mon Dec 25 02:28:47 2023 +++ src/bin/sh/expand.c Fri Dec 29 15:49:23 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: expand.c,v 1.143 2023/12/25 02:28:47 kre Exp $ */ +/* $NetBSD: expand.c,v 1.144 2023/12/29 15:49:23 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95"; #else -__RCSID("$NetBSD: expand.c,v 1.143 2023/12/25 02:28:47 kre Exp $"); +__RCSID("$NetBSD: expand.c,v 1.144 2023/12/29 15:49:23 kre Exp $"); #endif #endif /* not lint */ @@ -1206,7 +1206,7 @@ varvalue(const char *name, int quoted, i quoted ? ", quoted" : "", subtype, flag)); if (subtype == VSLENGTH) /* no magic required ... */ - flag &= ~EXP_FULL; + flag &= ~(EXP_FULL | EXP_QNEEDED); #define STRTODEST(p) \ do {\ @@ -1218,7 +1218,7 @@ varvalue(const char *name, int quoted, i } \ } else \ while (*p) { \ - if (ISCTL(*p)) \ + if ((flag & EXP_QNEEDED) && ISCTL(*p)) \ STPUTC(CTLESC, expdest); \ STPUTC(*p++, expdest); \ } \