aboutsummaryrefslogtreecommitdiffstats
path: root/libsbus.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-10-21 18:39:42 +0200
committerMattias Andrée <maandree@kth.se>2017-10-21 18:39:42 +0200
commitc8843d3391a1b2139255d46a23104ada9a12d207 (patch)
treee2a6a54a23a5372640ccfe8e83f4c88f74b554a6 /libsbus.c
parentAdd flags to functions using send (diff)
downloadsbus-c8843d3391a1b2139255d46a23104ada9a12d207.tar.gz
sbus-c8843d3391a1b2139255d46a23104ada9a12d207.tar.bz2
sbus-c8843d3391a1b2139255d46a23104ada9a12d207.tar.xz
libsbus_receive: check message length to avoid reading outside it
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libsbus.c')
-rw-r--r--libsbus.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libsbus.c b/libsbus.c
index 9b8b9ad..4a913ec 100644
--- a/libsbus.c
+++ b/libsbus.c
@@ -69,7 +69,7 @@ libsbus_receive(int fd, int flags, char *buf, union libsbus_packet *packet)
if (r < 0)
return -1;
- if (!strncmp(buf, "MSG ", 4)) {
+ if (r >= 4 && !strncmp(buf, "MSG ", 4)) {
p = memchr(buf, '\0', r);
if (!*p++)
goto unknown;