From 690bbe170d9ed4597629e4e986575fbe0a2cb796 Mon Sep 17 00:00:00 2001 From: Stanley Sufficool Date: Sat, 5 Oct 2013 09:54:45 -0700 Subject: [PATCH 1/4] FIX BUG #65219 - USE DB not being sent for FreeTDS version < 0.92 FreeTDS <0.92 does not support DBSETLDBNAME option and therefore will not work with SQL Azure. Fallback to dbuse command in letter versions. --- ext/pdo_dblib/dblib_driver.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c index 2aaf3975db18e..13444b89c3db6 100644 --- a/ext/pdo_dblib/dblib_driver.c +++ b/ext/pdo_dblib/dblib_driver.c @@ -350,9 +350,10 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ DBSETLAPP(H->login, vars[1].optval); +/* DBSETLDBNAME is only available in FreeTDS 0.92 or above */ #ifdef DBSETLDBNAME if (vars[3].optval) { - DBSETLDBNAME(H->login, vars[3].optval); + if(FAIL == DBSETLDBNAME(H->login, vars[3].optval)) goto cleanup; } #endif @@ -362,6 +363,16 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ goto cleanup; } +/* + * FreeTDS < 0.92 does not support the DBSETLDBNAME option + * Send use database here after login (Will not work with SQL Azure) + */ +#ifndef DBSETLDBNAME + if (vars[3].optval) { + if(FAIL == dbuse(H->link, vars[3].optval)) goto gleanup; + } +#endif + #if PHP_DBLIB_IS_MSSQL /* dblib do not return more than this length from text/image */ DBSETOPT(H->link, DBTEXTLIMIT, "2147483647"); @@ -377,23 +388,6 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ dbh->max_escaped_char_length = 2; dbh->alloc_own_columns = 1; -#if 0 - /* Cache the supported data types from the servers systypes table */ - if(dbcmd(H->link, "select usertype, name from systypes order by usertype") != FAIL) { - if(dbsqlexec(H->link) != FAIL) { - dbresults(H->link); - while (dbnextrow(H->link) == SUCCESS) { - val = dbdata(H->link, 1); - add_index_string(pdo_dblib_datatypes, *val, dbdata(H->link, 2), 1); - } - } - /* Throw out any remaining resultsets */ - dbcancel(H-link); - } -#endif - - - cleanup: for (i = 0; i < nvars; i++) { if (vars[i].freeme) { From 63f242178d33fa22346d2e976b06a76455dbd6ab Mon Sep 17 00:00:00 2001 From: Stanley Sufficool Date: Sat, 5 Oct 2013 20:59:20 -0700 Subject: [PATCH 2/4] FIX BUG #65219 - Typo correction --- ext/pdo_dblib/dblib_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c index 13444b89c3db6..daf5494d5839f 100644 --- a/ext/pdo_dblib/dblib_driver.c +++ b/ext/pdo_dblib/dblib_driver.c @@ -369,7 +369,7 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ */ #ifndef DBSETLDBNAME if (vars[3].optval) { - if(FAIL == dbuse(H->link, vars[3].optval)) goto gleanup; + if(FAIL == dbuse(H->link, vars[3].optval)) goto cleanup; } #endif From b5a0f128718d93a236b450bb9b409477f0a97888 Mon Sep 17 00:00:00 2001 From: ArunSK Date: Mon, 7 Oct 2013 00:26:49 +0200 Subject: [PATCH 3/4] fixing a minor typo in CODING_STANDARDS document --- CODING_STANDARDS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODING_STANDARDS b/CODING_STANDARDS index 7413be453ca6b..5ceacdc4dce55 100644 --- a/CODING_STANDARDS +++ b/CODING_STANDARDS @@ -151,7 +151,7 @@ Naming Conventions 7. Classes should be given descriptive names. Avoid using abbreviations where possible. Each word in the class name should start with a capital letter, - without underscore delimiters (CampelCaps starting with a capital letter). + without underscore delimiters (CamelCaps starting with a capital letter). The class name should be prefixed with the name of the 'parent set' (e.g. the name of the extension):: From b026993a74f452c5f6a689124b4ad4d7b3ac2491 Mon Sep 17 00:00:00 2001 From: Daniel Lowrey Date: Mon, 7 Oct 2013 15:02:48 -0400 Subject: [PATCH 4/4] Fixed segfault when built with OpenSSL >= 1.0.1 (PR #481) --- ext/openssl/openssl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index f1dfa5024ae95..a2cdfb5c1649a 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -4613,9 +4613,6 @@ SSL *php_SSL_new_from_context(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{ GET_VER_OPT_STRING("local_cert", certfile); if (certfile) { - X509 *cert = NULL; - EVP_PKEY *key = NULL; - SSL *tmpssl; char resolved_path_buff[MAXPATHLEN]; const char * private_key = NULL; @@ -4642,7 +4639,11 @@ SSL *php_SSL_new_from_context(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{ } } - tmpssl = SSL_new(ctx); +#if OPENSSL_VERSION_NUMBER < 0x10001001L + /* Unnecessary as of OpenSSLv1.0.1 (will segfault if used with >= 10001001 ) */ + X509 *cert = NULL; + EVP_PKEY *key = NULL; + SSL *tmpssl = SSL_new(ctx); cert = SSL_get_certificate(tmpssl); if (cert) { @@ -4651,7 +4652,7 @@ SSL *php_SSL_new_from_context(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{ EVP_PKEY_free(key); } SSL_free(tmpssl); - +#endif if (!SSL_CTX_check_private_key(ctx)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Private key does not match certificate!"); }