From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21716 invoked by alias); 16 Jan 2012 05:09:18 -0000 Received: (qmail 21697 invoked by uid 9699); 16 Jan 2012 05:09:17 -0000 Date: Mon, 16 Jan 2012 05:09:00 -0000 Message-ID: <20120116050917.21695.qmail@sourceware.org> From: mornfall@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/daemons/common daemon-shared.c Mailing-List: contact lvm2-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: lvm2-cvs-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00017.txt.bz2 CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2012-01-16 05:09:16 Modified files: daemons/common : daemon-shared.c Log message: Fix a boundary condition in read_buffer in daemon-shared.c. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-shared.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8 --- LVM2/daemons/common/daemon-shared.c 2012/01/15 11:17:16 1.7 +++ LVM2/daemons/common/daemon-shared.c 2012/01/16 05:09:16 1.8 @@ -30,20 +30,19 @@ if (result < 0 && errno != EAGAIN && errno != EWOULDBLOCK) goto fail; + if ((!strncmp((*buffer) + bytes - 4, "\n##\n", 4))) { + *(*buffer + bytes - 4) = 0; + break; /* success, we have the full message now */ + } + if (bytes == buffersize) { buffersize += 1024; if (!(new = realloc(*buffer, buffersize + 1))) goto fail; *buffer = new; - } else { - (*buffer)[bytes] = 0; - if ((end = strstr((*buffer) + bytes - 4, "\n##\n"))) { - *end = 0; - break; /* success, we have the full message now */ - } - /* TODO call select here if we encountered EAGAIN/EWOULDBLOCK */ } + /* TODO call select here if we encountered EAGAIN/EWOULDBLOCK */ } return 1; fail: