summaryrefslogtreecommitdiff
path: root/src/libsystemd-terminal
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-09-23 13:51:42 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2014-09-23 20:05:45 +0200
commita908d213557cfbe874b7bd1ae3a1b0d3c05c29e9 (patch)
treec3d786d892195a85c50bb495bbb49df1bc9460ac /src/libsystemd-terminal
parentc5e6bfc6bc46dd8bc187e035929d6a49cd23ec09 (diff)
terminal: verify kernel-returned DRM events are not truncated
Make sure the kernel always returns events properly. This is guaranteed right now, otherwise, we do something really wrong. But lets be sure and verify the received values properly. This also silences some coverity warnings.
Diffstat (limited to 'src/libsystemd-terminal')
-rw-r--r--src/libsystemd-terminal/grdev-drm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libsystemd-terminal/grdev-drm.c b/src/libsystemd-terminal/grdev-drm.c
index 5c65c096de..5393ebf988 100644
--- a/src/libsystemd-terminal/grdev-drm.c
+++ b/src/libsystemd-terminal/grdev-drm.c
@@ -2223,7 +2223,7 @@ static int grdrm_card_io_fn(sd_event_source *s, int fd, uint32_t revents, void *
for (i = 0; i < l; i += event->length) {
event = (void*)&buf[i];
- if (i + event->length > l) {
+ if (i + (ssize_t)sizeof(*event) > l || i + (ssize_t)event->length > l) {
log_debug("grdrm: %s/%s: truncated event", card->base.session->name, card->base.name);
break;
}