bash/backport-Bash-5.1-patch-14-fix-off-by-one-error-when-reading-.patch

29 lines
957 B
Diff

From 72912fb8209105af961c851260a173115efe60be Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
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
Conflict:NA
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=72912fb8209105af961c851260a173115efe60be
---
subst.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/subst.c b/subst.c
index dda1d55c..2b76256c 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.33.0