php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36720 chunk_split doesn't cut string property
Submitted: 2006-03-13 15:41 UTC Modified: 2006-03-27 01:00 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: astur103 at hotmail dot com Assigned:
Status: No Feedback Package: Unknown/Other Function
PHP Version: 5.1.2 OS: Windows XP Pro SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
16 + 7 = ?
Subscribe to this entry?

 
 [2006-03-13 15:41 UTC] astur103 at hotmail dot com
Description:
------------
Sometimes, above all if memory is clean or the function is not loaded in memory and has to do it, chunk_split cut a base64 string wrongly.

Later, works fine.

Reproduce code:
---------------
This is the used function:

function compress_gz($string, $level = "1") {
	$final_string = "";
	IF(!empty($string)) {
		$final_string = chunk_split(base64_encode(gzcompress($string, $level)));
	}
	return $final_string;
	unset($string);
	unset($final_string);
}


Expected result:
----------------
I guess that something like this ...

---- LAST 3 LINES OF STRING ---

0r5uCiYhgApgyg3dCkwmwrauUwVphDguNk2YXJFHqWtjYBAbJjL9iS4X14tgmvRNyD6ef+L3Ve3y
5eLawo1+GJjEDVylt2st73hav2fuh90XV7iJbHVZexbnfz9M2d8Yszv8AKlPYUQ==

---- END ----


Actual result:
--------------
---- LAST 3 LINES OF STRING ---

0r5uCiYhgApgyg3dCkwmwrauUwVphDguNk2YXJFHqWtjYBAbJjL9iS4X14tgmvRNyD6ef+L3Ve3y
5eLawo1+GJjEDVylt2st73hav2fuh90XV7iJbHVZexbnfz9M2d8=
Yszv8AKlPYUQ==

---- END ----


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-13 15:48 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.


 [2006-03-13 16:12 UTC] astur103 at hotmail dot com
1.- To uncompress or compress the string use ...

http://www.3dspanish.org/bug_report/functions.txt

2.- To check how chunk_split cut wrongly the string check ...

http://www.3dspanish.org/bug_report/bad_cut_code.txt

3.- To check the SAME string cut rightly check ...
http://www.3dspanish.org/bug_report/good_cut_code.txt

4.- To know how is the inside string use function "uncompress_gz"
over "good_cut_code.txt"

Let me know if you need something more.

Thanks

Mapg
 [2006-03-13 16:24 UTC] astur103 at hotmail dot com
Maybe problem is originated on base64_encode or gzcompress funtions, or ZLIB library.

Take also in consideration that I am using level 1 of compression.

With previous PHP versions, these functions worked finely, and always. Now with 5.1.2 and in my system, sometimes this bug happens.

Thanks

Mapg
 [2006-03-15 17:39 UTC] astur103 at hotmail dot com
Just a comment. I think that an important note.

There are 8 consecutive queries to compress_gz function.

1.- Before 5.1.2 (Win32), I had a usleep(100000) between these 8 queries.
2.- Now I have tested that need a usleep(200000) to get that the chunk_split works fine, or at least, the combination of chunk_split(base64_encode(gzcompress, 1)))

I hope this helps.

Thanks

Mapg
 [2006-03-19 18:01 UTC] mike@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip

Works fine here.
 [2006-03-27 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 18:01:28 2024 UTC