]> sourceware.org Git - lvm2.git/commitdiff
libdaemon: Fix an invalid memory read.
authorPetr Rockai <prockai@redhat.com>
Tue, 8 Oct 2013 21:19:11 +0000 (23:19 +0200)
committerPetr Rockai <prockai@redhat.com>
Tue, 8 Oct 2013 21:21:09 +0000 (23:21 +0200)
libdaemon/client/daemon-io.c

index 906f375471ec0eb5bb00ee4ede01704a8f39859e..e2c51800a2de4b0208b71e7542e064412387807d 100644 (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 */
This page took 0.055955 seconds and 5 git commands to generate.