|
7 | 7 | #include <sstream> |
8 | 8 | #include <string> |
9 | 9 | #include <vector> |
| 10 | +#include <algorithm> |
10 | 11 |
|
11 | 12 | enum class ParseStatus : int { |
12 | 13 | Success = 0, |
@@ -166,19 +167,21 @@ ParseStatus watch_stdin(std::vector<uint8_t> &data, additional_info &info) |
166 | 167 | if (line.find("_COREDUMP_START_") != std::string::npos) { |
167 | 168 | data.clear(); |
168 | 169 |
|
169 | | - do { |
170 | | - std::getline(std::cin, line); |
171 | | - } while (line.empty()); |
172 | | - |
173 | | - auto pos = line.find(": "); |
174 | | - if (pos == std::string::npos) { |
175 | | - std::cerr << "Error: Missing process and exception in first line!" |
| 170 | + if (!std::getline(std::cin, line, ':')) { |
| 171 | + std::cerr << "Error: Missing first line with process and exception!" |
176 | 172 | << std::endl; |
177 | 173 | return ParseStatus::CoredumpCorrupted; |
178 | 174 | } |
| 175 | + line.erase(std::remove(line.begin(), line.end(), '\n'), line.end()); |
| 176 | + info.process_name = line; |
179 | 177 |
|
180 | | - info.process_name = line.substr(0, pos); |
181 | | - info.exception = line.substr(pos + 2); |
| 178 | + if (!std::getline(std::cin, line, ';')) { |
| 179 | + std::cerr << "Error: Missing first line with process and exception!" |
| 180 | + << std::endl; |
| 181 | + return ParseStatus::CoredumpCorrupted; |
| 182 | + } |
| 183 | + line.erase(std::remove(line.begin(), line.end(), '\n'), line.end()); |
| 184 | + info.exception = line; |
182 | 185 |
|
183 | 186 | return read_decode(data, info.crc32); |
184 | 187 | } |
|
0 commit comments