diff options
| author | 2019-04-01 11:58:43 -0700 | |
|---|---|---|
| committer | 2019-04-01 11:58:43 -0700 | |
| commit | 3d8c00e84b705b4797352103e883d18ea04e6af8 (patch) | |
| tree | 79e755c10d133915129649f4dcbce3e838a9b635 | |
| parent | 5aeb884114e79a3cf493c1e0cd3472983fa1e066 (diff) | |
| parent | 72051fdd3519c1c34342239ee0c5c1a10d0bad33 (diff) | |
Merge "view_compiler.cpp: clean up file descriptor handling"
am: 72051fdd35
Change-Id: I8b64aa76cd1f835dc38dcdc01ceaaf552695bb2c
| -rw-r--r-- | cmds/installd/view_compiler.cpp | 10 | ||||
| -rw-r--r-- | cmds/installd/view_compiler.h | 2 | 
2 files changed, 4 insertions, 8 deletions
diff --git a/cmds/installd/view_compiler.cpp b/cmds/installd/view_compiler.cpp index f1ac7178f6..60d6492e70 100644 --- a/cmds/installd/view_compiler.cpp +++ b/cmds/installd/view_compiler.cpp @@ -45,7 +45,7 @@ bool view_compiler(const char* apk_path, const char* package_name, const char* o      // and pass file descriptors.      // Open input file -    unique_fd infd{open(apk_path, 0)}; +    unique_fd infd{open(apk_path, O_RDONLY)}; // NOLINT(android-cloexec-open)      if (infd.get() < 0) {          PLOG(ERROR) << "Could not open input file: " << apk_path;          return false; @@ -53,7 +53,7 @@ bool view_compiler(const char* apk_path, const char* package_name, const char* o      // Set up output file. viewcompiler can't open outputs by fd, but it can write to stdout, so      // we close stdout and open it towards the right output. -    unique_fd outfd{open(out_dex_file, O_CREAT | O_TRUNC | O_WRONLY, 0644)}; +    unique_fd outfd{open(out_dex_file, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, 0644)};      if (outfd.get() < 0) {          PLOG(ERROR) << "Could not open output file: " << out_dex_file;          return false; @@ -62,10 +62,6 @@ bool view_compiler(const char* apk_path, const char* package_name, const char* o          PLOG(ERROR) << "Could not change output file permissions";          return false;      } -    if (close(STDOUT_FILENO) != 0) { -        PLOG(ERROR) << "Could not close stdout"; -        return false; -    }      if (dup2(outfd, STDOUT_FILENO) < 0) {          PLOG(ERROR) << "Could not duplicate output file descriptor";          return false; @@ -96,4 +92,4 @@ bool view_compiler(const char* apk_path, const char* package_name, const char* o  }  } // namespace installd -} // namespace android
\ No newline at end of file +} // namespace android diff --git a/cmds/installd/view_compiler.h b/cmds/installd/view_compiler.h index f7c6e57722..aa141ca257 100644 --- a/cmds/installd/view_compiler.h +++ b/cmds/installd/view_compiler.h @@ -26,4 +26,4 @@ bool view_compiler(const char* apk_path, const char* package_name, const char* o  } // namespace installd  } // namespace android -#endif // VIEW_COMPILER_H_
\ No newline at end of file +#endif // VIEW_COMPILER_H_  |