[ZBX-2084] When output of script >65535 symbols, data getting by the web-interface is corrupted and truncated Created: 2010 Mar 01  Updated: 2017 May 30  Resolved: 2010 Mar 29

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 1.8.1
Fix Version/s: 1.8.2

Type: Incident report Priority: Major
Reporter: Fyodor Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

php


Attachments: XML File style-file.xml    
Issue Links:
Duplicate
is duplicated by ZBX-2085 CJSON->decode corrupt big length data Closed

 Description   

in file include/scripts.inc.php in function execute_script() we see $res = socket_read($socket, 65535);
It means that data longer than 65535 bytes will be corrupted.
Fix:
$reply = "";
do {
$recv = "";
$recv = socket_read($socket, '1400');
if($recv != "")

{ $reply .= $recv; }

} while($recv != "");



 Comments   
Comment by Alexei Vladishev [ 2010 Mar 24 ]

Note that we must have a reasonable limit, say 1MB.

Comment by Maxim Andruhovich (Inactive) [ 2010 Mar 26 ]

added timeout and memory limit constants and removed sockets API usage

svn://svn.zabbix.com/branches/dev/ZBX-2084

Comment by Maxim Andruhovich (Inactive) [ 2010 Mar 29 ]

Changed only data processing way, nothing else.

Yep, Zabbix don't require PHP sockets API extension to be installed anymore.

Comment by richlv [ 2010 Mar 29 ]

dev branch rev 11178

running a test script which just printed an xml file :

Undefined index: value[/usr/local/apache2/htdocs/dev/ZBX-2084/include/forms.inc.php:6409]

Comment by richlv [ 2010 Mar 29 ]

testcase - when used as the script output, error mentioned above appears

Comment by Maxim Andruhovich (Inactive) [ 2010 Mar 29 ]

Server returns wrong JSON encoded string

Comment by Maxim Andruhovich (Inactive) [ 2010 Mar 29 ]

all bugs with sockets are fixed, as well as JSON on the frontend. There is not properly encoded JSON coming from a server side.

Comment by Fyodor [ 2010 Mar 29 ]

Ok, simple test, that show uncorrectly work of class.cjson.
[inakrin@fpaligin ~/zabbix-1.8.2/frontends/php]$ php -v
PHP 5.2.12 (cli) (built: Feb 16 2010 17:49:56)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
Try to execute this code:
<?php
require_once "include/classes/class.cjson.php";
require_once "include/func.inc.php";
$arrt = array("value"=>file_get_contents("/home/inakrin/style-file.xml"));
$strJ = json_encode($arrt);
$json = new CJSON();
var_dump($json->decode($strJ, true));
var_dump(json_decode($strJ, true));

Comment by Maxim Andruhovich (Inactive) [ 2010 Mar 29 ]

svn://svn.zabbix.com/branches/dev/ZBX-2084

Comment by richlv [ 2010 Mar 29 ]

confirming the fix in dev branch rev 11206.

Comment by Maxim Andruhovich (Inactive) [ 2010 Mar 29 ]

Bug fixed in version pre 1.8.2 revision 11209

Generated at Thu Jun 05 22:43:52 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.