crash_sender: fix orphan logic, prevent deletion of *.log.tar.xz
get_base() was broken for files with multiple extensions which leads the orphan
logic to delete all such files that are older than 1 day. This patch set fixes
get_base().
BUG=chromium:338977
TEST=manual test of code fragment
TEST=`cbuildbot {arm,amd64,x86}-generic-full` pass
CQ-DEPEND=CL:199820
Change-Id: I1b712f1a5cfc848e5bc2a86c97e0a3e88ce6250d
Reviewed-on: https://chromium-review.googlesource.com/199511
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/crash_reporter/crash_collector.cc b/crash_reporter/crash_collector.cc
index 89d9304..5ddff08 100644
--- a/crash_reporter/crash_collector.cc
+++ b/crash_reporter/crash_collector.cc
@@ -108,6 +108,8 @@
}
std::string CrashCollector::Sanitize(const std::string &name) {
+ // Make sure the sanitized name does not include any periods.
+ // The logic in crash_sender relies on this.
std::string result = name;
for (size_t i = 0; i < name.size(); ++i) {
if (!isalnum(result[i]) && result[i] != '_')
diff --git a/crash_reporter/crash_sender b/crash_reporter/crash_sender
index 565d949..e42cb02 100755
--- a/crash_reporter/crash_sender
+++ b/crash_reporter/crash_sender
@@ -212,10 +212,11 @@
return 0
}
-# Gets the base part of a crash report file, such as
-# name.01234.5678.9012 from name.01234.5678.9012.meta
+# Gets the base part of a crash report file, such as name.01234.5678.9012 from
+# name.01234.5678.9012.meta or name.01234.5678.9012.log.tar.xz. We make sure
+# "name" is sanitized in CrashCollector::Sanitize to not include any periods.
get_base() {
- echo "${1%.*}"
+ echo "$1" | cut -d. -f-4
}
get_extension() {