diff options
Diffstat (limited to 'src/firejail/util.c')
-rw-r--r-- | src/firejail/util.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/firejail/util.c b/src/firejail/util.c index 03f52fabb..c3e00a110 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c | |||
@@ -683,11 +683,12 @@ int remove_directory(const char *path) { | |||
683 | void flush_stdin(void) { | 683 | void flush_stdin(void) { |
684 | if (isatty(STDIN_FILENO)) { | 684 | if (isatty(STDIN_FILENO)) { |
685 | int cnt = 0; | 685 | int cnt = 0; |
686 | ioctl(STDIN_FILENO, FIONREAD, &cnt); | 686 | int rv = ioctl(STDIN_FILENO, FIONREAD, &cnt); |
687 | if (cnt) { | 687 | if (rv == 0 && cnt) { |
688 | if (!arg_quiet) | 688 | if (!arg_quiet) |
689 | printf("Warning: removing %d bytes from stdin\n", cnt); | 689 | printf("Warning: removing %d bytes from stdin\n", cnt); |
690 | ioctl(STDIN_FILENO, TCFLSH, TCIFLUSH); | 690 | rv = ioctl(STDIN_FILENO, TCFLSH, TCIFLUSH); |
691 | (void) rv; | ||
691 | } | 692 | } |
692 | } | 693 | } |
693 | } | 694 | } |
@@ -700,6 +701,7 @@ void create_empty_dir_as_root(const char *dir, mode_t mode) { | |||
700 | if (stat(dir, &s)) { | 701 | if (stat(dir, &s)) { |
701 | if (arg_debug) | 702 | if (arg_debug) |
702 | printf("Creating empty %s directory\n", dir); | 703 | printf("Creating empty %s directory\n", dir); |
704 | /* coverity[toctou] */ | ||
703 | if (mkdir(dir, mode) == -1) | 705 | if (mkdir(dir, mode) == -1) |
704 | errExit("mkdir"); | 706 | errExit("mkdir"); |
705 | if (set_perms(dir, 0, 0, mode)) | 707 | if (set_perms(dir, 0, 0, mode)) |
@@ -717,6 +719,7 @@ void create_empty_file_as_root(const char *fname, mode_t mode) { | |||
717 | if (arg_debug) | 719 | if (arg_debug) |
718 | printf("Creating empty %s file\n", fname); | 720 | printf("Creating empty %s file\n", fname); |
719 | 721 | ||
722 | /* coverity[toctou] */ | ||
720 | FILE *fp = fopen(fname, "w"); | 723 | FILE *fp = fopen(fname, "w"); |
721 | if (!fp) | 724 | if (!fp) |
722 | errExit("fopen"); | 725 | errExit("fopen"); |