|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From a908d213557cfbe874b7bd1ae3a1b0d3c05c29e9 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: David Herrmann <dh.herrmann@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Tue, 23 Sep 2014 13:51:42 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] terminal: verify kernel-returned DRM events are not truncated
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Make sure the kernel always returns events properly. This is guaranteed
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
right now, otherwise, we do something really wrong. But lets be sure and
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
verify the received values properly. This also silences some coverity
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
warnings.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/grdev-drm.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/grdev-drm.c b/src/libsystemd-terminal/grdev-drm.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 5c65c096de..5393ebf988 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/grdev-drm.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/grdev-drm.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -2223,7 +2223,7 @@ static int grdrm_card_io_fn(sd_event_source *s, int fd, uint32_t revents, void *
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (i = 0; i < l; i += event->length) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
event = (void*)&buf[i];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (i + event->length > l) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (i + (ssize_t)sizeof(*event) > l || i + (ssize_t)event->length > l) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
log_debug("grdrm: %s/%s: truncated event", card->base.session->name, card->base.name);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
break;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|