1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

libdaemon: Fix an invalid memory read.

This commit is contained in:
Petr Rockai 2013-10-08 23:19:11 +02:00
parent d888a0557e
commit 808a5d945e

View File

@ -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 */