PHP 4.0 Bug #6419 Updated: Curl output has extra data in output

From: Date: Mon, 11 Sep 2000 03:02:12 +0000
Subject: PHP 4.0 Bug #6419 Updated: Curl output has extra data in output
Groups: php.dev 
Request: Send a blank email to php-dev+get-32862@lists.php.net to get a copy of this message
ID: 6419 User Update by: medvitz@medvitz.net Status: Open Bug Type: cURL related Description: Curl output has extra data in output 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 Previous Comments: --------------------------------------------------------------------------- [2000-09-04 13:17:22] sterling@php.net Moving to cURL related. --------------------------------------------------------------------------- [2000-08-29 14:24:11] medvitz@medvitz.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 --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=6419

« previous php.dev (#32862) next »