=== modified file 'src/helper.cc' --- src/helper.cc 2012-11-24 14:30:02 +0000 +++ src/helper.cc 2012-12-04 14:09:50 +0000 @@ -915,43 +915,44 @@ if (flag != COMM_OK || len == 0) { srv->closePipesSafely(); return; } srv->roffset += len; srv->rbuf[srv->roffset] = '\0'; debugs(84, 9, "helperHandleRead: '" << srv->rbuf << "'"); if (!srv->stats.pending) { /* someone spoke without being spoken to */ debugs(84, DBG_IMPORTANT, "helperHandleRead: unexpected read from " << hlp->id_name << " #" << srv->index + 1 << ", " << (int)len << " bytes '" << srv->rbuf << "'"); srv->roffset = 0; srv->rbuf[0] = '\0'; } - while ((t = strchr(srv->rbuf, hlp->eom))) { + char *msg = srv->rbuf; + while(*msg == '\0' && (msg - srv->rbuf) < srv->roffset) msg++; + while ((t = strchr(msg, hlp->eom))) { /* end of reply found */ - char *msg = srv->rbuf; int i = 0; debugs(84, 3, "helperHandleRead: end of reply found"); if (t > srv->rbuf && t[-1] == '\r' && hlp->eom == '\n') t[-1] = '\0'; *t = '\0'; if (hlp->childs.concurrency) { i = strtol(msg, &msg, 10); while (*msg && xisspace(*msg)) ++msg; } helperReturnBuffer(i, srv, hlp, msg, t); // only skip off the \0 _after_ passing its location to helperReturnBuffer ++t; }