cvs: php4 /main network.c

From: Date: Mon, 18 Mar 2002 19:42:19 +0000
Subject: cvs: php4 /main network.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10365@lists.php.net to get a copy of this message
wez Mon Mar 18 14:42:19 2002 EDT Modified files: /php4/main network.c Log: Fix for bugs #16148, #11199, #10092: fread from socket will never free memory. This patch should also be applied to php_sockread_internal in fsock.c in the 4.2 branch. Index: php4/main/network.c diff -u php4/main/network.c:1.39 php4/main/network.c:1.40 --- php4/main/network.c:1.39 Mon Mar 18 13:54:31 2002 +++ php4/main/network.c Mon Mar 18 14:42:19 2002 @@ -15,7 +15,7 @@ | Author: Stig Venaas <venaas@uninett.no> | +----------------------------------------------------------------------+ */ -/* $Id: network.c,v 1.39 2002/03/18 18:54:31 wez Exp $ */ +/* $Id: network.c,v 1.40 2002/03/18 19:42:19 wez Exp $ */ #define PHP_SOCK_CHUNK_SIZE 8192 #define MAX_CHUNKS_PER_READ 10 @@ -633,6 +633,14 @@ #endif nr_bytes = recv(sock->socket, buf, sock->chunk_size, 0); if(nr_bytes > 0) { + + /* try to avoid ever expanding buffer */ + if (sock->readpos > 0) { + memmove(sock->readbuf, READPTR(sock), sock->readbuflen - sock->readpos); + sock->writepos -= sock->readpos; + sock->readpos = 0; + } + if(sock->writepos + nr_bytes > sock->readbuflen) { sock->readbuflen += sock->chunk_size; sock->readbuf = perealloc(sock->readbuf, sock->readbuflen,

« previous php.cvs (#10365) next »