mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
output options: expand ~
This commit is contained in:
parent
a25e4a1011
commit
02ebd9a099
1 changed files with 10 additions and 2 deletions
|
|
@ -50,13 +50,21 @@ void check_output(int argc, char **argv) {
|
|||
if (!outindex)
|
||||
return;
|
||||
|
||||
|
||||
// check filename
|
||||
drop_privs(0);
|
||||
char *outfile = argv[outindex];
|
||||
outfile += (enable_stderr)? 16:9;
|
||||
|
||||
// check filename
|
||||
invalid_filename(outfile, 0); // no globbing
|
||||
|
||||
// expand user home directory
|
||||
if (outfile[0] == '~') {
|
||||
char *full;
|
||||
if (asprintf(&full, "%s%s", cfg.homedir, outfile + 1) == -1)
|
||||
errExit("asprintf");
|
||||
outfile = full;
|
||||
}
|
||||
|
||||
// do not accept directories, links, and files with ".."
|
||||
if (strstr(outfile, "..") || is_link(outfile) || is_dir(outfile)) {
|
||||
fprintf(stderr, "Error: invalid output file. Links, directories and files with \"..\" are not allowed.\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue