[PATCH] fixup! commands: cat: add support for concatenating into file

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Feb 26 01:40:30 PST 2026


commands: cat: move mode flags to open call with O_CREAT

To placate static analysis, 0666 was added to the open call, but at the
wrong callsite: It should be added for the open that has O_CREAT as
open flag.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 commands/cat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/commands/cat.c b/commands/cat.c
index e29d39225c71..57cf532fac24 100644
--- a/commands/cat.c
+++ b/commands/cat.c
@@ -55,7 +55,7 @@ static int do_cat(int argc, char *argv[])
 		return COMMAND_ERROR_USAGE;
 
 	if (outfile) {
-		outfd = open(outfile, oflags);
+		outfd = open(outfile, oflags, 0666);
 		if (outfd < 0) {
 			perror("open");
 			return 1;
@@ -65,7 +65,7 @@ static int do_cat(int argc, char *argv[])
 	buf = xmalloc(BUFSIZE);
 
 	for (int args = 0; args < argc; args++) {
-		fd = open(argv[args], O_RDONLY, 0666);
+		fd = open(argv[args], O_RDONLY);
 		if (fd < 0) {
 			err = 1;
 			printf("could not open %s: %m\n", argv[args]);
-- 
2.47.3




More information about the barebox mailing list