Off by one error in strlen($json)

Andrea Venturoli <[email protected]> Wed, 4 Sep 2019 16:18:41 +0200
Newsgroups gmane.network.cacti.user
Message-ID <[email protected]>
Hello.

I've got three Cacti installations, all with FreeBSD 11.2/amd64 + PHP 
7.2.22 + MySQL 5.6.45.

Two are working fine, one is giving me a lot of headaches...

It all began at the beginning of this year, when I tried upgrading to 
version 1.2.0. The upgrade kept failing and I was suggested to do a 
manual upgrade (which I did).

Since then graphs were not displayed (with an error window).

I found the solution was to modify graph_json.php, changing the last 
lines from:
> header('Content-Length: ' . strlen($json));
> print $json;
to
> header('Content-Length: ' . strlen($json)+1);
> print $json;

I was able to do all subsequent upgrades up to 1.2.4 regardless of this 
patching (which I obviously had to do over and over); however, upgrading 
to 1.2.5 required me to make the same change to install/step_json.php.
Luckily, it seems only these two files use this function in this way, 
but I'm not sure.

Now Cacti seems to be working, but I'd like to understand what's going on.
Any hint on what to check?

  bye & Thanks
	av.