From 72912fb8209105af961c851260a173115efe60be Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Tue, 4 Jan 2022 16:59:40 -0500 Subject: [PATCH] Bash-5.1 patch 14: fix off-by-one error when reading multibyte characters from command substitution output --- patchlevel.h | 2 +- subst.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/patchlevel.h b/patchlevel.h index d8a1b2a9d..f2e80d19c 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -25,6 +25,6 @@ regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh looks for to find the patch level (for the sccs version string). */ -#define PATCHLEVEL 13 +#define PATCHLEVEL 14 #endif /* _PATCHLEVEL_H_ */ diff --git a/subst.c b/subst.c index dda1d55cc..2b76256c6 100644 --- a/subst.c +++ b/subst.c @@ -6242,7 +6242,7 @@ read_comsub (fd, quoted, flags, rflag) /* read a multibyte character from buf */ /* punt on the hard case for now */ memset (&ps, '\0', sizeof (mbstate_t)); - mblen = mbrtowc (&wc, bufp-1, bufn+1, &ps); + mblen = mbrtowc (&wc, bufp-1, bufn, &ps); if (MB_INVALIDCH (mblen) || mblen == 0 || mblen == 1) istring[istring_index++] = c; else -- 2.47.3