php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6419 Curl output has extra data in output
Submitted: 2000-08-29 14:24 UTC Modified: 2000-09-10 23:48 UTC
From: medvitz at medvitz dot net Assigned:
Status: Closed Package: cURL related
PHP Version: 4.0 Latest CVS (29/08/2000) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: medvitz at medvitz dot net
New email:
PHP Version: OS:

 

 [2000-08-29 14:24 UTC] medvitz at medvitz dot net

I've got two test programs as listed.

test.php

<?
phpinfo();
?>

test1.php

<?
$ch = curl_init("http://10.0.0.100/test.php");
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"a=bb&r=beer");
echo curl_exec($ch);
curl_close($ch);
?>

when I run test1.php through a browser, I get 'extra' characters periodically through the page.  The characters are '????v?@'.  

The php config is :

./configure' '--prefix=/usr' '--with-apxs=/usr/sbin/apxs'
                                     '--with-config-file-path=/etc/httpd' '--enable-safe-mode'
                                     '--with-exec-dir=/usr/bin' '--with-system-regex' '--disable-debug'
                                     '--enable-debugger' '--enable-magic-quotes' '--enable-track-vars'
                                     '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--with-xml'
                                     '--with-ftp' '--with-pgsql' '--enable-wddx' '--with-curl=../curl-7.1.1' '--with-zlib'



Thanks,

Dave

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-04 13:17 UTC] sterling@php.net
Moving to cURL related.
 [2000-09-10 23:02 UTC] medvitz at medvitz dot net

I tracked down this problem.  Basically, the strcat function was the culprit.  In the curl_exec function I added a unsigned long pos, and then changed the loop that looked like

while ((b = fread(buf, 1, sizeof(buf), fp)) > 0) {
strcat(ret_data, buf);
}

to

pos = 0;
while ((b = fread(buf, 1, sizeof(buf), fp)) > 0) {
	memcpy(&(ret_data[pos]), buf,b);
	pos += b;
}
ret_data[stat_sb.st_size-1]='\0';


If someone with CVS access could fix this....


Also, I've made a mod to my code with respects to  bug 6656
This is a problem that I was having, and just corrected in my source.
Basically, the curl_handle pointer in the curl_init() function never gets malloc() ed.

I added the following line immediately following the variable declarations, and it resolved the issue.

curl_handle = (php_curl *)malloc(sizeof(php_curl));

WARNING.  Someone who is more adept with the PHP internals, please verify this solution, as I fear that it may cause a memory leak somewhere, and am not sure where to properly clean this up!!!!!

I apologize for putting this info here, but, I can't add it to the bug report as I do not have CVS access.

Thanks,
Dave		


 [2000-09-10 23:48 UTC] sterling@php.net
Fixed in CVS.  Thanks!
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Nov 25 00:01:23 2020 UTC