aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/firejail/ls.c8
-rw-r--r--src/man/firejail.txt4
2 files changed, 10 insertions, 2 deletions
diff --git a/src/firejail/ls.c b/src/firejail/ls.c
index 7c7f8b75f..4d0a001b6 100644
--- a/src/firejail/ls.c
+++ b/src/firejail/ls.c
@@ -233,10 +233,16 @@ void cat(const char *path) {
233 fprintf(stderr, "Error: %s is not a regular file\n", path); 233 fprintf(stderr, "Error: %s is not a regular file\n", path);
234 exit(1); 234 exit(1);
235 } 235 }
236 bool tty = isatty(STDOUT_FILENO);
236 237
237 int c; 238 int c;
238 while ((c = fgetc(fp)) != EOF) 239 while ((c = fgetc(fp)) != EOF) {
240 // file is untrusted
241 // replace control characters when printing to a terminal
242 if (tty && c != '\t' && c != '\n' && iscntrl((unsigned char) c))
243 c = '?';
239 fputc(c, stdout); 244 fputc(c, stdout);
245 }
240 fflush(stdout); 246 fflush(stdout);
241 fclose(fp); 247 fclose(fp);
242} 248}
diff --git a/src/man/firejail.txt b/src/man/firejail.txt
index abb73b5e2..3b7ba4e3d 100644
--- a/src/man/firejail.txt
+++ b/src/man/firejail.txt
@@ -3036,7 +3036,9 @@ and transfer files between the container and the host filesystem.
3036 3036
3037.TP 3037.TP
3038\fB\-\-cat=name|pid filename 3038\fB\-\-cat=name|pid filename
3039Write content of a container file to standard out. 3039Write content of a container file to standard out. The container is specified by name or PID.
3040If standard out is a terminal, all ASCII control characters except new line and horizontal tab
3041are replaced.
3040 3042
3041.TP 3043.TP
3042\fB\-\-get=name|pid filename 3044\fB\-\-get=name|pid filename