Index: third_party/crashpad/crashpad/tools/crashpad_database_util.cc |
diff --git a/third_party/crashpad/crashpad/tools/crashpad_database_util.cc b/third_party/crashpad/crashpad/tools/crashpad_database_util.cc |
index e7d89bc438ceb9aef32bbcccbcb3917f699605b6..b2c4cb497cb0eb688ce05011790e92f8b084ce87 100644 |
--- a/third_party/crashpad/crashpad/tools/crashpad_database_util.cc |
+++ b/third_party/crashpad/crashpad/tools/crashpad_database_util.cc |
@@ -560,13 +560,21 @@ int DatabaseUtilMain(int argc, char* argv[]) { |
return EXIT_FAILURE; |
} |
+ bool used_stdin = false; |
for (const base::FilePath new_report_path : options.new_report_paths) { |
std::unique_ptr<FileReaderInterface> file_reader; |
- bool is_stdin = false; |
if (new_report_path.value() == FILE_PATH_LITERAL("-")) { |
- is_stdin = true; |
- file_reader.reset(new WeakStdioFileReader(stdin)); |
+ if (used_stdin) { |
+ fprintf(stderr, |
+ "%" PRFilePath |
+ ": Only one --new-report may be read from standard input\n", |
+ me.value().c_str()); |
+ return EXIT_FAILURE; |
+ } |
+ used_stdin = true; |
+ file_reader.reset(new WeakFileHandleFileReader( |
+ StdioFileHandle(StdioStream::kStandardInput))); |
} else { |
std::unique_ptr<FileReader> file_path_reader(new FileReader()); |
if (!file_path_reader->Open(new_report_path)) { |
@@ -597,7 +605,7 @@ int DatabaseUtilMain(int argc, char* argv[]) { |
!LoggingWriteFile(new_report->handle, buf, read_result)) { |
return EXIT_FAILURE; |
} |
- } while (read_result == sizeof(buf)); |
+ } while (read_result > 0); |
call_error_writing_crash_report.Disarm(); |
@@ -607,13 +615,6 @@ int DatabaseUtilMain(int argc, char* argv[]) { |
return EXIT_FAILURE; |
} |
- file_reader.reset(); |
- if (is_stdin) { |
- if (fclose(stdin) == EOF) { |
- STDIO_PLOG(ERROR) << "fclose"; |
- } |
- } |
- |
const char* prefix = (show_operations > 1) ? "New report ID: " : ""; |
printf("%s%s\n", prefix, uuid.ToString().c_str()); |
} |