coreutils/backport-yes-avoid-failure-on-CHERI-protected-systems.patch
2025-03-05 14:30:38 +08:00

37 lines
1.1 KiB
Diff

From 261f13bcf84a6f7a3241bab48c074879db789fca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <P@draigBrady.com>
Date: Wed, 15 Jan 2025 22:08:07 +0000
Subject: [PATCH] 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)
Reference:https://github.com/coreutils/coreutils/commit/261f13bcf84a6f7a3241bab48c074879db789fca
Conflict:NA
---
src/yes.c | 5 +++++
1 file changed, 5 insertions(+)
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);
--
2.43.0