]> granicus.if.org Git - php/commitdiff
Fix some issues with gzFile and fsockopen.
authorWez Furlong <wez@php.net>
Sat, 16 Mar 2002 18:42:42 +0000 (18:42 +0000)
committerWez Furlong <wez@php.net>
Sat, 16 Mar 2002 18:42:42 +0000 (18:42 +0000)
ext/standard/fsock.c
ext/zlib/zlib.c
ext/zlib/zlib_fopen_wrapper.c

index 530dcdd21a9dcaad7ebda8e936b5fc99710c6250..e3d3342f275df4a2b074907cfa2f6053b39a8cd7 100644 (file)
@@ -159,7 +159,7 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                ZVAL_STRING(zerrno, "", 1);
        }
 
-       if (port != -1) { /* connect to a host */
+       if (port > 0)   { /* connect to a host */
                enum php_sslflags_t { php_ssl_none, php_ssl_v23, php_ssl_tls };
                enum php_sslflags_t ssl_flags;
                struct {
@@ -195,6 +195,11 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 #endif
                stream = php_stream_sock_open_host(host, port, socktype, (int)timeout, persistent);
 
+               if (stream == NULL) {
+                       zend_error(E_WARNING, "%s(): unable to connect to %s:%d", 
+                                       get_active_function_name(TSRMLS_C), host, port);
+               }
+               
 #if HAVE_OPENSSL_EXT
                if (stream)     {
                        int ssl_ret = FAILURE;
index a0c54fbd81758cc31f350f3e9ad7007b17931ec3..44edcbdcd320a84addd8a709c5b1859225f2e9dd 100644 (file)
@@ -257,7 +257,7 @@ static gzFile php_gzopen_wrapper(char *path, char *mode, int options TSRMLS_DC)
 
        stream = php_stream_open_wrapper(path, mode, options | REPORT_ERRORS, NULL TSRMLS_CC);
        if (stream)     {
-               if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD | PHP_STREAM_CAST_TRY_HARD, (void**)&fd, 1))
+               if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD|PHP_STREAM_CAST_TRY_HARD, (void**)&fd, 1))
                {
                        gzFile ret = gzdopen(fd, mode);
                        if (ret)        {
@@ -302,8 +302,8 @@ PHP_FUNCTION(gzfile)
        convert_to_string_ex(filename);
 
        /* using a stream here is a bit more efficient (resource wise) than php_gzopen_wrapper */
-       stream = php_stream_gzopen(Z_STRVAL_PP(filename), "r", use_include_path|ENFORCE_SAFE_MODE, NULL TSRMLS_CC);
-       if (!stream) {
+       stream = php_stream_gzopen(Z_STRVAL_PP(filename), "rb", use_include_path|ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL TSRMLS_CC);
+       if (stream == NULL) {
                php_error(E_WARNING,"gzFile(\"%s\") - %s",Z_STRVAL_PP(filename),strerror(errno));
                RETURN_FALSE;
        }
index 31589f824b4e2ed3e17159f150b33fa81b713829..5d3129f8435a078fea646ef5c16ccf18df85d005 100644 (file)
@@ -86,10 +86,9 @@ php_stream *php_stream_gzopen(char *path, char *mode, int options, char **opened
        php_stream *stream = NULL;
        
        self = emalloc(sizeof(*self));
-       
-       while(*path != ':')
-               path++;
-       path++;
+
+       if (strncmp("zlib:", path, 5) == 0)
+               path += 5;
        
        self->stream = php_stream_open_wrapper(path, mode, options, opened_path TSRMLS_CC);