diff options
author | 2021-07-21 23:56:26 +0200 | |
---|---|---|
committer | 2021-07-21 23:56:26 +0200 | |
commit | 02ebd9a0998917c6b60d8a9d16cd6430cdd8dc26 (patch) | |
tree | 97ab609a6cea1c17a073cbe4453ef60797e06250 /src | |
parent | new profiles (diff) | |
download | firejail-02ebd9a0998917c6b60d8a9d16cd6430cdd8dc26.tar.gz firejail-02ebd9a0998917c6b60d8a9d16cd6430cdd8dc26.tar.zst firejail-02ebd9a0998917c6b60d8a9d16cd6430cdd8dc26.zip |
output options: expand ~
Diffstat (limited to 'src')
-rw-r--r-- | src/firejail/output.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/firejail/output.c b/src/firejail/output.c index 835dff2db..ce10ab157 100644 --- a/src/firejail/output.c +++ b/src/firejail/output.c | |||
@@ -50,13 +50,21 @@ void check_output(int argc, char **argv) { | |||
50 | if (!outindex) | 50 | if (!outindex) |
51 | return; | 51 | return; |
52 | 52 | ||
53 | |||
54 | // check filename | ||
55 | drop_privs(0); | 53 | drop_privs(0); |
56 | char *outfile = argv[outindex]; | 54 | char *outfile = argv[outindex]; |
57 | outfile += (enable_stderr)? 16:9; | 55 | outfile += (enable_stderr)? 16:9; |
56 | |||
57 | // check filename | ||
58 | invalid_filename(outfile, 0); // no globbing | 58 | invalid_filename(outfile, 0); // no globbing |
59 | 59 | ||
60 | // expand user home directory | ||
61 | if (outfile[0] == '~') { | ||
62 | char *full; | ||
63 | if (asprintf(&full, "%s%s", cfg.homedir, outfile + 1) == -1) | ||
64 | errExit("asprintf"); | ||
65 | outfile = full; | ||
66 | } | ||
67 | |||
60 | // do not accept directories, links, and files with ".." | 68 | // do not accept directories, links, and files with ".." |
61 | if (strstr(outfile, "..") || is_link(outfile) || is_dir(outfile)) { | 69 | if (strstr(outfile, "..") || is_link(outfile) || is_dir(outfile)) { |
62 | fprintf(stderr, "Error: invalid output file. Links, directories and files with \"..\" are not allowed.\n"); | 70 | fprintf(stderr, "Error: invalid output file. Links, directories and files with \"..\" are not allowed.\n"); |