Skip to contentSkip to conversation

master - libdaemon: Fix an invalid memory read.

PATCH Petr Rockai 1 participant 1 message Oct 8, 2013

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=808a5d945e3af27c7e79093f38d2dbe8370fee39
Commit:        808a5d945e3af27c7e79093f38d2dbe8370fee39
Parent:        d888a0557efc173336582ca94055e0630d5ceca8
Author:        Petr Rockai <[email protected]>
AuthorDate:    Tue Oct 8 23:19:11 2013 +0200
Committer:     Petr Rockai <[email protected]>
CommitterDate: Tue Oct 8 23:21:09 2013 +0200

libdaemon: Fix an invalid memory read.

---
 libdaemon/client/daemon-io.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
libdaemon/client/daemon-io.c +1 -1
index 906f375..e2c5180 100644
@@ -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 */