php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15057 getimagesize() crashes when offline
Submitted: 2002-01-15 16:35 UTC Modified: 2002-01-21 02:54 UTC
From: jonatan at cyberdude dot com Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 4.1.1 OS: Mac OS X 10.1.2 (Build 5P48)
Private report: No CVE-ID: None
 [2002-01-15 16:35 UTC] jonatan at cyberdude dot com
when i am offline from the internet and access a file which 
contains only:

  <?php getimagesize( "http://www.php.net/image.gif" ); ?>

httpd crashes. i am using the precompiled apache php module 
version 4.1.1 from <http://www.entropy.ch/software/macosx/
php/> on macosx 10.1.2. the configure line is:

'./configure' '--with-mysql' '--with-pgsql' '--with-apxs' 
'--with-gd=/usr/local' '--with-png-dir=/usr/local' '--with-
zlib-dir=/usr' '--with-jpeg-dir=/usr/local' '--with-
freetype-dir=/usr/local' '--enable-trans-sid' '--enable-
exif' '--with-xml' '--enable-wddx' '--with-curl=/usr/local' 
'--with-pdflib=/usr/local' '--with-t1lib=/usr/local' '--
enable-ftp' '--enable-bcmath'

and the crashlog:

**********

Date/Time:  2002-01-15 16:02:50 +0100
OS Version: 10.1.2 (Build 5P48)
Host:       localhost

Command:    httpd
PID:        771

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x0000001c

Thread 0 Crashed:
 #0   0x00a27d50 in php_network_getaddresses
 #1   0x00a2800c in php_hostconnect
 #2   0x00aba634 in php_fopen_url_wrap_http
 #3   0x00a24ae0 in php_fopen_url_wrapper
 #4   0x00a24278 in php_fopen_wrapper
 #5   0x00abbc68 in zif_getimagesize
 #6   0x00a057c0 in execute
 #7   0x009f0f64 in zend_execute_scripts
 #8   0x00a27158 in php_execute_script
 #9   0x00a23d34 in apache_php_module_main
 #10  0x00a227e0 in send_php
 #11  0x0000c5ac in ap_invoke_handler
 #12  0x00016530 in process_request_internal
 #13  0x000165ac in ap_process_request
 #14  0x00005d5c in child_main
 #15  0x00005fcc in make_child
 #16  0x0000631c in perform_idle_server_maintenance
 #17  0x000068a0 in standalone_main
 #18  0x00006f64 in main
 #19  0x00001e18 in _start
 #20  0x00001c48 in start

PPC Thread State:
  srr0: 0x00a27d50 srr1: 0x0000d030                vrsave: 
0x00000000
   xer: 0x20000020   lr: 0x00a27d20  ctr: 0x70025330   mq: 
0x00000000
    r0: 0x00a27d20   r1: 0xbfffb3a0   r2: 0xbfff6d90   r3: 
0x00000002
    r4: 0x00000000   r5: 0xbfffb238   r6: 0xbfffb2e8   r7: 
0x00000803
    r8: 0x00000000   r9: 0x00000000  r10: 0x00000000  r11: 
0x2422228b
   r12: 0x70025330  r13: 0x00000000  r14: 0x00000000  r15: 
0x00000000
   r16: 0x00000000  r17: 0x00000004  r18: 0x00bfd0c4  r19: 
0xbfffdae0
   r20: 0x00000000  r21: 0xbfffdae4  r22: 0x00000000  r23: 
0x00000000
   r24: 0xbfffdae4  r25: 0x0021c4c0  r26: 0x00bfd0c4  r27: 
0x00000001
   r28: 0xbfffb450  r29: 0x00000000  r30: 0x0021c860  r31: 
0x00a27cd8

**********

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-20 18:23 UTC] jonatan at cyberdude dot com
i have recompiled php with --enable-debug, and managed to 
make a backtrace. hth...

'./configure' '--with-apxs' '--enable-debug'

Program received signal EXC_BAD_ACCESS, Could not access 
memory.
0x005275b8 in php_network_getaddresses (host=0x1794e8 
"www.php.net", sal=0xbfffade0) at network.c:151
151     network.c: No such file or directory.
        in network.c
(gdb) bt
#0  0x005275b8 in php_network_getaddresses (host=0x1794e8 
"www.php.net", sal=0xbfffade0) at network.c:151
#1  0x005278b0 in php_hostconnect (host=0x2 <Address 0x2 
out of bounds>, port=80, socktype=1, timeout=0) at 
network.c:289
#2  0x00584870 in php_fopen_url_wrap_http (path=0x1844f8 
"http://www.php.net/image.gif", mode=0x5cc550 "rb", 
options=4, issock=0xbfffd470, socketd=0xbfffd474, 
opened_path=0x0) at http_fopen_wrapper.c:100
#3  0x005241bc in php_fopen_url_wrapper (path=0x1844f8 
"http://www.php.net/image.gif", mode=0x5cc550 "rb", 
options=4, issock=0xbfffd470, socketd=0xbfffd474, 
opened_path=0x0) at fopen_wrappers.c:538
#4  0x0052383c in php_fopen_wrapper (path=0x1844f8 "http://
www.php.net/image.gif", mode=0x5cc550 "rb", options=0, 
issock=0xbfffac78, socketd=0x1103, opened_path=0x0) at 
fopen_wrappers.c:256
#5  0x00586080 in zif_getimagesize (ht=1, return_value=
0x1790f8, this_ptr=0xbfffabc8, return_value_used=-
1073763208) at image.c:439
#6  0x00503428 in execute (op_array=0x184468) at ./
zend_execute.c:1590
#7  0x004eddcc in zend_execute_scripts (type=2, retval=0x0, 
file_count=3) at zend.c:814
#8  0x00526954 in php_execute_script (primary_file=
0xbfffea98) at main.c:1307
#9  0x005232bc in apache_php_module_main (r=0x2, 
display_source_mode=0) at sapi_apache.c:90
#10 0x00521d44 in send_php (r=0x1770a8, 
display_source_mode=0, filename=0x0) at mod_php4.c:575
#11 0x0000c5ac in ap_invoke_handler ()
#12 0x00016530 in process_request_internal ()
#13 0x000165ac in ap_process_request ()
#14 0x00005d5c in child_main ()
#15 0x00005f18 in make_child ()
#16 0x00006084 in startup_children ()
#17 0x000066a8 in standalone_main ()
#18 0x00006f64 in main ()
#19 0x00001e18 in _start ()
#20 0x00001c48 in start ()
(gdb) 

 [2002-01-20 19:40 UTC] markonen@php.net
When offline, Mac OS X's getaddrinfo() returns a null 
pointer for results, but does not return an error code. PHP 
didn't check for this, it will in the next release. Here's 
the patch; I will close this bug when it's in the cvs 
(could someone review and commit?):

diff -c -r1.26 network.c
*** network.c   6 Jan 2002 22:45:43 -0000       1.26
--- network.c   21 Jan 2002 00:38:16 -0000
***************
*** 150,155 ****
--- 150,158 ----
        if ((n = getaddrinfo(host, NULL, &hints, &res))) {
            php_error(E_WARNING, "php_network_getaddresses: 
getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
            return 0;
+       } else if (res == NULL) {
+           php_error(E_WARNING, "php_network_getaddresses: 
getaddrinfo failed (null result pointer)");
+           return 0;
        }
  
        sai = res;

 [2002-01-21 02:54 UTC] derick@php.net
Fixed in CVS. Thank for your report.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 28 20:01:26 2024 UTC