From 808a5d945e3af27c7e79093f38d2dbe8370fee39 Mon Sep 17 00:00:00 2001 From: Petr Rockai Date: Tue, 8 Oct 2013 23:19:11 +0200 Subject: [PATCH] libdaemon: Fix an invalid memory read. --- libdaemon/client/daemon-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdaemon/client/daemon-io.c b/libdaemon/client/daemon-io.c index 906f37547..e2c51800a 100644 --- a/libdaemon/client/daemon-io.c +++ b/libdaemon/client/daemon-io.c @@ -38,7 +38,7 @@ int buffer_read(int fd, struct buffer *buffer) { result = read(fd, buffer->mem + buffer->used, buffer->allocated - buffer->used); if (result > 0) { buffer->used += result; - if (!strncmp((buffer->mem) + buffer->used - 4, "\n##\n", 4)) { + if (buffer->used >= 4 && !strncmp((buffer->mem) + buffer->used - 4, "\n##\n", 4)) { buffer->used -= 4; buffer->mem[buffer->used] = 0; break; /* success, we have the full message now */ -- 2.43.5