Skip to content

Commit

Permalink
liblog: fix reading pmsg
Browse files Browse the repository at this point in the history
d3ecc66b9c "liblog: support extended logger_entry headers" removed
the logger_entry::msg variable and instead uses hdr_size as an offset
from logger_entry to where the message starts in parent log_msg
buffer.

In pmsg, hdr_size is not recorded and therefore uninitialized when it
was referenced, causing corruption when reading last logcat.  This
change uses sizeof(log_msg->entry) instead.

Bug: 158263230
Test: last logcat works
Merged-In: Ic01e73bf4d8ba8419cc770138565aa1210a6078b
Change-Id: Ic01e73bf4d8ba8419cc770138565aa1210a6078b
(cherry picked from commit 34d7bd98adc080041202cceec4626fd88b4b6e88)

Former-commit-id: 709d56924170dc60dadbf3e69a27abe4c46c60ea
  • Loading branch information
Tom Cherry committed Jun 17, 2020
1 parent 562efd3 commit a42e58c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion liblog/pmsg_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int PmsgRead(struct logger_list* logger_list, struct log_msg* log_msg) {
((logger_list->start.tv_sec != buf.l.realtime.tv_sec) ||
(logger_list->start.tv_nsec <= buf.l.realtime.tv_nsec)))) &&
(!logger_list->pid || (logger_list->pid == buf.p.pid))) {
char* msg = reinterpret_cast<char*>(&log_msg->entry) + log_msg->entry.hdr_size;
char* msg = reinterpret_cast<char*>(&log_msg->entry) + sizeof(log_msg->entry);
*msg = buf.prio;
fd = atomic_load(&logger_list->fd);
if (fd <= 0) {
Expand Down

0 comments on commit a42e58c

Please sign in to comment.