|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10860 final char deleted with CURLOPT_RETURNTRANSFER
Submitted: 2001-05-14 16:17 UTC Modified: 2001-05-14 17:08 UTC
From: sr2899 at hotmail dot com Assigned:
Status: Closed Package: cURL related
PHP Version: 4.0.4pl1 OS: Linux
Private report: No CVE-ID: None
 [2001-05-14 16:17 UTC] sr2899 at hotmail dot com
I noticed a while ago that CURLOPT_RETURNTRANSFER added trailing null chars to the end of html pages, which seemed odd, but didn't seem like a bug.  Then I noticed that on binary files, in fact what it does is REPLACE the trailing char with a null char.

Oddly, setting CURLOPT_HEADER to 1 seems to fix the problem.

		$f = fopen('/tmp/bla1','w');
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,"");
		curl_setopt($ch, CURLOPT_FILE,$f);

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,"");
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$ret = curl_exec($ch);

		$f = fopen('/tmp/bla2','w');
		$ret = fwrite($f,$ret,strlen($ret));
		system('diff /tmp/bla2 /tmp/bla1');


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-14 17:08 UTC]
Should be fixed in CVS (by Sterling):

Try the latest cvs of cURL and set the CURLOPT_BINARYTRANSFER option
along with the CURLOPT_RETURNTRANSFER option.

please reopen if this does not work.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Sep 28 05:01:24 2023 UTC