From nobody Fri Apr 26 21:22:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490810252905985.6697637290039; Wed, 29 Mar 2017 10:57:32 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5689B7EBA1; Wed, 29 Mar 2017 17:57:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 214FF60F8B; Wed, 29 Mar 2017 17:57:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 605C041287; Wed, 29 Mar 2017 17:57:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2THq4G5016493 for ; Wed, 29 Mar 2017 13:52:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 863FB84718; Wed, 29 Mar 2017 17:52:04 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F09B84717 for ; Wed, 29 Mar 2017 17:52:02 +0000 (UTC) Received: from swiftbird.org (92-255-100-1.customer.comfortel.pro [92.255.100.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72F8064DA5 for ; Wed, 29 Mar 2017 17:51:59 +0000 (UTC) Received: from vtolstov by swiftbird.org with local (Exim 4.87) (envelope-from ) id 1ctHlF-0000ej-90 for libvir-list@redhat.com; Wed, 29 Mar 2017 20:51:57 +0300 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5689B7EBA1 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=selfip.ru Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5689B7EBA1 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 72F8064DA5 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=selfip.ru Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=vtolstov@swiftbird.org DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 72F8064DA5 From: Vasiliy Tolstov To: libvir-list@redhat.com Date: Wed, 29 Mar 2017 20:51:57 +0300 Message-Id: <20170329175157.2428-2-v.tolstov@selfip.ru> In-Reply-To: <20170329175157.2428-1-v.tolstov@selfip.ru> References: <20170329175157.2428-1-v.tolstov@selfip.ru> X-Greylist: Delayed for 31:25:43 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 29 Mar 2017 17:52:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 29 Mar 2017 17:52:00 +0000 (UTC) for IP:'92.255.100.1' DOMAIN:'92-255-100-1.customer.comfortel.pro' HELO:'swiftbird.org' FROM:'vtolstov@swiftbird.org' RCPT:'' X-RedHat-Spam-Score: 1.783 * (BAYES_50, HEADER_FROM_DIFFERENT_DOMAINS, RDNS_DYNAMIC) 92.255.100.1 92-255-100-1.customer.comfortel.pro 92.255.100.1 92-255-100-1.customer.comfortel.pro X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] [libvirt-php] fix libvirt_stream_send/libvirt_stream_recv X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 29 Mar 2017 17:57:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vasiliy Tolstov --- src/libvirt-php.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index e8384795d635..4e088e746281 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -178,9 +178,15 @@ ZEND_ARG_INFO(0, stats) ZEND_ARG_INFO(0, flags) ZEND_END_ARG_INFO() =20 -ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_stream_send, 0, 0, 2) +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_stream_send, 0, 1, 2) ZEND_ARG_INFO(0, conn) -ZEND_ARG_INFO(0, data) +ZEND_ARG_INFO(1, data) +ZEND_ARG_INFO(0, len) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_stream_recv, 0, 1, 2) +ZEND_ARG_INFO(0, conn) +ZEND_ARG_INFO(1, data) ZEND_ARG_INFO(0, len) ZEND_END_ARG_INFO() =20 @@ -595,7 +601,7 @@ static zend_function_entry libvirt_functions[] =3D { PHP_FE(libvirt_stream_abort, arginfo_libvirt_conn) PHP_FE(libvirt_stream_finish, arginfo_libvirt_conn) PHP_FE(libvirt_stream_send, arginfo_libvirt_stream_se= nd) - PHP_FE(libvirt_stream_recv, arginfo_libvirt_stream_se= nd) + PHP_FE(libvirt_stream_recv, arginfo_libvirt_stream_re= cv) /* Domain functions */ PHP_FE(libvirt_domain_new, arginfo_libvirt_domain_ne= w) PHP_FE(libvirt_domain_new_get_vnc, arginfo_libvirt_void) @@ -4509,7 +4515,7 @@ PHP_FUNCTION(libvirt_stream_finish) /* * Function name: libvirt_stream_recv * Since version: 0.5.0 - * Description: Function is used to close stream from libvirt conn + * Description: Function is used to recv from stream via libvirt conn * Arguments: @res [resource]: libvirt stream resource from libvirt_= stream_create() * @data [string]: buffer * @len [int]: amout of data to recieve @@ -4518,8 +4524,8 @@ PHP_FUNCTION(libvirt_stream_finish) PHP_FUNCTION(libvirt_stream_recv) { zval *zstream, *zbuf; - char *recv_buf; php_libvirt_stream *stream =3D NULL; + char *recv_buf =3D NULL; int retval =3D -1; zend_long length =3D 0; =20 @@ -4534,31 +4540,24 @@ PHP_FUNCTION(libvirt_stream_recv) =20 retval =3D virStreamRecv(stream->stream, recv_buf, length); if (retval < 0) { - efree(recv_buf); - zval_dtor(zbuf); - ZVAL_NULL(zbuf); + zval_dtor(zbuf); + ZVAL_NULL(zbuf); } else { recv_buf[retval] =3D '\0'; -#if PHP_MAJOR_VERSION >=3D 7 - ZVAL_STRINGL(zbuf, recv_buf, retval); - efree(recv_buf); -#else - ZVAL_STRINGL(zbuf, recv_buf, retval, 0); -#endif + VIRT_ZVAL_STRINGL(zbuf, recv_buf, retval); } =20 if (retval =3D=3D -1) { set_error("Cannot recv from stream" TSRMLS_CC); - RETURN_LONG(retval); } - + efree(recv_buf); RETURN_LONG(retval); } =20 /* * Function name: libvirt_stream_send * Since version: 0.5.0 - * Description: Function is used to close stream from libvirt conn + * Description: Function is used to send to stream via libvirt conn * Arguments: @res [resource]: libvirt stream resource from libvirt_= stream_create() * @data [string]: buffer * @length [int]: amout of data to send @@ -4571,7 +4570,6 @@ PHP_FUNCTION(libvirt_stream_send) int retval =3D -1; zend_long length =3D 0; char *cstr; - //int cstrlen; =20 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream,= &zbuf, &length) =3D=3D FAILURE) RETURN_LONG(retval); @@ -4580,12 +4578,10 @@ PHP_FUNCTION(libvirt_stream_send) RETURN_LONG(retval); =20 cstr =3D Z_STRVAL_P(zbuf); - //cstrlen =3D Z_STRLEN_P(zbuf); =20 retval =3D virStreamSend(stream->stream, cstr, length); if (retval =3D=3D -1) { set_error("Cannot send to stream" TSRMLS_CC); - RETURN_LONG(retval); } =20 RETURN_LONG(retval); --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list