diff options
author | Pavel Kosov <kosov.pavel@huawei.com> | 2021-10-29 13:24:28 +0300 |
---|---|---|
committer | Pavel Kosov <kosov.pavel@huawei.com> | 2021-10-29 13:24:28 +0300 |
commit | 5d5836721d48fbfa37c4b6f4313f94fdc65eae44 (patch) | |
tree | f8b1aa6048bbf82f901c37f0dd1c9fdc3189a24e | |
parent | 28b6eb35d301801c85b6080c2422fd35c3ed509a (diff) |
[LNT] Fixed possible crash or junk data in cPerf
The return value of the first call of Dump.next() was not checked. Dump.getText() returned an uninitialized string (a junk string) if the objdump did not return an usable data for the specified address range. It caused a crash or inconsistent profile data.
OS Laboratory. Huawei Russian Research Institute. Saint-Petersburg
Reviewed By: thopre
Differential Revision: https://reviews.llvm.org/D112782
-rw-r--r-- | lnt/testing/profile/cPerf.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lnt/testing/profile/cPerf.cpp b/lnt/testing/profile/cPerf.cpp index e812338..b8fd4c0 100644 --- a/lnt/testing/profile/cPerf.cpp +++ b/lnt/testing/profile/cPerf.cpp @@ -365,6 +365,7 @@ public: void reset(Map *M, uint64_t Start, uint64_t Stop) { ThisAddress = 0; + ThisText = ""; if (Stream) { fclose(Stream); wait(NULL); @@ -396,6 +397,7 @@ public: ssize_t Len = getline(&Line, &LineLen, Stream); if (Len == -1) { ThisAddress = EndAddress; + ThisText = ""; return; } char *TokBuf; @@ -757,10 +759,9 @@ void PerfReader::emitSymbol( uint64_t Adjust) { ObjdumpOutput Dump(Objdump, BinaryCacheRoot); Dump.reset(&M, Sym.Start, Sym.End); - Dump.next(); emitFunctionStart(Sym.Name); - for (uint64_t I = Sym.Start; I < Sym.End; I = Dump.next()) { + for (uint64_t I = Dump.next(); I < Sym.End; I = Dump.next()) { auto PC = Event->first - Adjust; auto Text = Dump.getText(); |