aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2025-01-15 22:08:07 +0000
committerPádraig Brady <P@draigBrady.com>2025-01-15 22:16:30 +0000
commit261f13bcf84a6f7a3241bab48c074879db789fca (patch)
tree8712c087ce210664328364072956317cc16f9a43
parenttac: avoid out of bounds access (diff)
downloadcoreutils-261f13bcf84a6f7a3241bab48c074879db789fca.tar.gz
coreutils-261f13bcf84a6f7a3241bab48c074879db789fca.zip
yes: avoid failure on CHERI protected systems
* src/yes.c (main): Don't reuse the argv array as CHERI's capability bounds do not allow for that, failing like: $ yes $(seq 156) | head -n1 In-address space security exception (core dumped)
-rw-r--r--src/yes.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/yes.c b/src/yes.c
index 396618cb5..ceb7ce447 100644
--- a/src/yes.c
+++ b/src/yes.c
@@ -96,6 +96,11 @@ main (int argc, char **argv)
reuse_operand_strings = false;
}
+#if defined __CHERI__
+ /* Cheri capability bounds do not allow for this. */
+ reuse_operand_strings = false;
+#endif
+
/* Fill the buffer with one copy of the output. If possible, reuse
the operands strings; this wins when the buffer would be large. */
char *buf = reuse_operand_strings ? *operands : xmalloc (bufalloc);