Loading libs/input/InputTransport.cpp +35 −23 Original line number Diff line number Diff line Loading @@ -96,28 +96,42 @@ inline static const char* toString(bool value) { // --- InputMessage --- bool InputMessage::isValid(size_t actualSize) const { if (size() == actualSize) { if (size() != actualSize) { ALOGE("Received message of incorrect size %zu (expected %zu)", actualSize, size()); return false; } switch (header.type) { case Type::KEY: return true; case Type::MOTION: return body.motion.pointerCount > 0 && body.motion.pointerCount <= MAX_POINTERS; case Type::MOTION: { const bool valid = body.motion.pointerCount > 0 && body.motion.pointerCount <= MAX_POINTERS; if (!valid) { ALOGE("Received invalid MOTION: pointerCount = %" PRIu32, body.motion.pointerCount); } return valid; } case Type::FINISHED: return true; case Type::FOCUS: return true; case Type::CAPTURE: return true; case Type::DRAG: return true; case Type::TIMELINE: case Type::TIMELINE: { const nsecs_t gpuCompletedTime = body.timeline.graphicsTimeline[GraphicsTimeline::GPU_COMPLETED_TIME]; const nsecs_t presentTime = body.timeline.graphicsTimeline[GraphicsTimeline::PRESENT_TIME]; return presentTime > gpuCompletedTime; const bool valid = presentTime > gpuCompletedTime; if (!valid) { ALOGE("Received invalid TIMELINE: gpuCompletedTime = %" PRId64 " presentTime = %" PRId64, gpuCompletedTime, presentTime); } return valid; } } ALOGE("Invalid message type: %" PRIu32, header.type); return false; } Loading Loading @@ -404,9 +418,7 @@ status_t InputChannel::receiveMessage(InputMessage* msg) { } if (!msg->isValid(nRead)) { #if DEBUG_CHANNEL_MESSAGES ALOGD("channel '%s' ~ received invalid message", mName.c_str()); #endif ALOGE("channel '%s' ~ received invalid message of size %zd", mName.c_str(), nRead); return BAD_VALUE; } Loading libs/input/tests/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -49,8 +49,8 @@ cc_test { cc_library_static { name: "StructLayout_test", srcs: ["StructLayout_test.cpp"], compile_multilib: "both", cflags: [ "-O0", "-Wall", "-Werror", "-Wextra", Loading Loading
libs/input/InputTransport.cpp +35 −23 Original line number Diff line number Diff line Loading @@ -96,28 +96,42 @@ inline static const char* toString(bool value) { // --- InputMessage --- bool InputMessage::isValid(size_t actualSize) const { if (size() == actualSize) { if (size() != actualSize) { ALOGE("Received message of incorrect size %zu (expected %zu)", actualSize, size()); return false; } switch (header.type) { case Type::KEY: return true; case Type::MOTION: return body.motion.pointerCount > 0 && body.motion.pointerCount <= MAX_POINTERS; case Type::MOTION: { const bool valid = body.motion.pointerCount > 0 && body.motion.pointerCount <= MAX_POINTERS; if (!valid) { ALOGE("Received invalid MOTION: pointerCount = %" PRIu32, body.motion.pointerCount); } return valid; } case Type::FINISHED: return true; case Type::FOCUS: return true; case Type::CAPTURE: return true; case Type::DRAG: return true; case Type::TIMELINE: case Type::TIMELINE: { const nsecs_t gpuCompletedTime = body.timeline.graphicsTimeline[GraphicsTimeline::GPU_COMPLETED_TIME]; const nsecs_t presentTime = body.timeline.graphicsTimeline[GraphicsTimeline::PRESENT_TIME]; return presentTime > gpuCompletedTime; const bool valid = presentTime > gpuCompletedTime; if (!valid) { ALOGE("Received invalid TIMELINE: gpuCompletedTime = %" PRId64 " presentTime = %" PRId64, gpuCompletedTime, presentTime); } return valid; } } ALOGE("Invalid message type: %" PRIu32, header.type); return false; } Loading Loading @@ -404,9 +418,7 @@ status_t InputChannel::receiveMessage(InputMessage* msg) { } if (!msg->isValid(nRead)) { #if DEBUG_CHANNEL_MESSAGES ALOGD("channel '%s' ~ received invalid message", mName.c_str()); #endif ALOGE("channel '%s' ~ received invalid message of size %zd", mName.c_str(), nRead); return BAD_VALUE; } Loading
libs/input/tests/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -49,8 +49,8 @@ cc_test { cc_library_static { name: "StructLayout_test", srcs: ["StructLayout_test.cpp"], compile_multilib: "both", cflags: [ "-O0", "-Wall", "-Werror", "-Wextra", Loading