Re: cvs: php4 /main network.c
| From: | Wez Furlong | Date: | Mon, 18 Mar 2002 19:46:35 +0000 |
| Subject: | Re: cvs: php4 /main network.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-10367@lists.php.net to get a copy of this message | ||
Can someone do what is needed to apply this fix to the 4.2 branch;
it's not a straight MFH, but the added lines can be literally added
straight into the relevant place in fsock.c.
I don't have time to checkout the relevant branch stuff and test
etc. etc.
--Wez.
On 19/03/02, "Wez Furlong" <wez.php@thebrainroom.com> wrote:
> 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,
>
>
>
> --
> PHP CVS Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php