diff options
author | Rene Ladan <rene@FreeBSD.org> | 2020-07-23 16:31:18 +0000 |
---|---|---|
committer | Rene Ladan <rene@FreeBSD.org> | 2020-07-23 16:31:18 +0000 |
commit | 651302b592fe54c5197641402df87ff216c27903 (patch) | |
tree | 784a10fc6050d3be8786fd6f4f954d7802bd9204 /www/iridium/files/patch-base_process_internal__linux.cc | |
parent | Add compiler:c++14-lang to USES to atttempt to fix on GCC-based systems: (diff) |
www/iridium: update to 2020.04.81
PR: 245959
Submitted by: Matthias Wolf
MFH: 2020Q3
Security: any Chromium vulnerability between 73 and 81
Diffstat (limited to 'www/iridium/files/patch-base_process_internal__linux.cc')
-rw-r--r-- | www/iridium/files/patch-base_process_internal__linux.cc | 95 |
1 files changed, 88 insertions, 7 deletions
diff --git a/www/iridium/files/patch-base_process_internal__linux.cc b/www/iridium/files/patch-base_process_internal__linux.cc index ca42b91c4296..abfff7cd44ce 100644 --- a/www/iridium/files/patch-base_process_internal__linux.cc +++ b/www/iridium/files/patch-base_process_internal__linux.cc @@ -1,16 +1,97 @@ ---- base/process/internal_linux.cc.orig 2019-03-11 22:00:51 UTC +--- base/process/internal_linux.cc.orig 2020-03-16 18:39:41 UTC +++ base/process/internal_linux.cc -@@ -60,10 +60,13 @@ bool ReadProcFile(const FilePath& file, std::string* b - // Synchronously reading files in /proc is safe. - ThreadRestrictions::ScopedAllowIO allow_io; +@@ -29,7 +29,11 @@ namespace internal { -+#if !defined(OS_BSD) - if (!ReadFileToString(file, buffer)) { + const char kProcDir[] = "/proc"; + ++#if defined(OS_BSD) ++const char kStatFile[] = "status"; ++#else + const char kStatFile[] = "stat"; ++#endif + + FilePath GetProcPidDir(pid_t pid) { + return FilePath(kProcDir).Append(NumberToString(pid)); +@@ -64,6 +68,7 @@ bool ReadProcFile(const FilePath& file, std::string* b DLOG(WARNING) << "Failed to read " << file.MaybeAsASCII(); return false; } -+#endif + return !buffer->empty(); } +@@ -79,6 +84,22 @@ bool ParseProcStats(const std::string& stats_data, + if (stats_data.empty()) + return false; + ++#if defined(OS_BSD) ++ proc_stats->clear(); ++ ++ std::vector<std::string> other_stats = SplitString( ++ stats_data, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); ++ ++ for (const auto& i : other_stats) { ++ auto pos = i.find(','); ++ ++ if (pos == std::string::npos) { ++ proc_stats->push_back(i); ++ } else { ++ proc_stats->push_back(i.substr(0, pos)); ++ } ++ } ++#else + // The stat file is formatted as: + // pid (process name) data1 data2 .... dataN + // Look for the closing paren by scanning backwards, to avoid being fooled by +@@ -108,6 +129,7 @@ bool ParseProcStats(const std::string& stats_data, + base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); + for (const auto& i : other_stats) + proc_stats->push_back(i); ++#endif + return true; + } + +@@ -155,7 +177,11 @@ int64_t ReadProcStatsAndGetFieldAsInt64(pid_t pid, Pro + } + + int64_t ReadProcSelfStatsAndGetFieldAsInt64(ProcStatsFields field_num) { ++#if defined(OS_BSD) ++ FilePath stat_file = FilePath(kProcDir).Append("curproc").Append(kStatFile); ++#else + FilePath stat_file = FilePath(kProcDir).Append("self").Append(kStatFile); ++#endif + return ReadStatFileAndGetFieldAsInt64(stat_file, field_num); + } + +@@ -171,6 +197,9 @@ size_t ReadProcStatsAndGetFieldAsSizeT(pid_t pid, + } + + Time GetBootTime() { ++#if defined(OS_BSD) ++ return Time(); ++#else + FilePath path("/proc/stat"); + std::string contents; + if (!ReadProcFile(path, &contents)) +@@ -184,9 +213,13 @@ Time GetBootTime() { + if (!StringToInt(btime_it->second, &btime)) + return Time(); + return Time::FromTimeT(btime); ++#endif + } + + TimeDelta GetUserCpuTimeSinceBoot() { ++#if defined(OS_BSD) ++ return TimeDelta(); ++#else + FilePath path("/proc/stat"); + std::string contents; + if (!ReadProcFile(path, &contents)) +@@ -210,6 +243,7 @@ TimeDelta GetUserCpuTimeSinceBoot() { + return TimeDelta(); + + return ClockTicksToTimeDelta(user + nice); ++#endif + } + + TimeDelta ClockTicksToTimeDelta(int clock_ticks) { |