void-packages/srcpkgs/gsmartcontrol/patches/upstream-gsmartcontrol-0.87...

45 lines
2.1 KiB
Diff

Fix provided by upstream gsmartcontrol.sf.net, in
HomePage > News > 2015-04-29:
The Linux binary packages have been updated with a patch that fixes crash on
startup for some smartmontools version and system configuration combinations.
The source patch can be downloaded separately as well. Note that he fix has
been included in the SVN version for some time now.
direct link for this patch:
fix https://build.opensuse.org/source/home:alex_sh/gsmartcontrol/gsmartcontrol_parser_crash_fix.diff?rev=da33e1d56b052b483f576e5e6823da3b
Index: src/applib/smartctl_parser.cpp
===================================================================
--- src/applib/smartctl_parser.cpp (revision 106)
+++ src/applib/smartctl_parser.cpp (revision 107)
@@ -201,21 +201,20 @@
while (section_start_pos != std::string::npos
&& (section_start_pos = s.find("===", section_start_pos)) != std::string::npos) {
- tmp_pos = s.find("\n", section_start_pos); // works with \r\n too.
+ tmp_pos = s.find("\n", section_start_pos); // works with \r\n too. This may be npos if nothing follows the header.
// trim is needed to remove potential \r in the end
std::string section_header = hz::string_trim_copy(s.substr(section_start_pos,
(tmp_pos == std::string::npos ? tmp_pos : (tmp_pos - section_start_pos)) ));
- if (tmp_pos != std::string::npos)
- ++tmp_pos; // set to start of the next section
-
- section_end_pos = s.find("===", tmp_pos); // start of the next section
- std::string section_body_str = hz::string_trim_copy(s.substr(tmp_pos,
- (section_end_pos == std::string::npos ? section_end_pos : section_end_pos - tmp_pos)));
-
+ std::string section_body_str;
+ if (tmp_pos != std::string::npos) {
+ section_end_pos = s.find("===", tmp_pos); // start of the next section
+ section_body_str = hz::string_trim_copy(s.substr(tmp_pos,
+ (section_end_pos == std::string::npos ? section_end_pos : section_end_pos - tmp_pos)));
+ }
status = parse_section(section_header, section_body_str) || status;
- section_start_pos = section_end_pos;
+ section_start_pos = (tmp_pos == std::string::npos ? std::string::npos : section_end_pos);
}
if (!status) {