liblog: accept log messages with hdr_size greater than known headers
We don't need to be so strict about this comparison. It's possible that logd will extend the message that it passes to readers in the future, and since we have a hdr_size parameter it can do so in a backwards compatible way, as long as we loosen this restriction. This keeps a sane upper bound that the hdr_size cannot be larger than the log message itself. Test: logcat, liblog-unit-tests Change-Id: I8a6bea2a2d6e3315d998c51c1029e466ff06b45f
This commit is contained in:
parent
f7a6c4587f
commit
8d2225353c
|
@ -114,7 +114,7 @@ struct log_msg {
|
|||
}
|
||||
char* msg() {
|
||||
unsigned short hdr_size = entry.hdr_size;
|
||||
if (hdr_size != sizeof(entry)) {
|
||||
if (hdr_size >= sizeof(struct log_msg) - sizeof(entry)) {
|
||||
return nullptr;
|
||||
}
|
||||
return reinterpret_cast<char*>(buf) + hdr_size;
|
||||
|
|
|
@ -120,7 +120,8 @@ int android_logger_list_read(struct logger_list* logger_list, struct log_msg* lo
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (log_msg->entry.hdr_size != sizeof(log_msg->entry)) {
|
||||
if (log_msg->entry.hdr_size < sizeof(log_msg->entry) ||
|
||||
log_msg->entry.hdr_size >= sizeof(struct log_msg) - sizeof(log_msg->entry)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue