Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32423 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37156 invoked by uid 1010); 23 Sep 2007 10:02:08 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 37141 invoked from network); 23 Sep 2007 10:02:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Sep 2007 10:02:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=alexandra@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=alexandra@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: alexandra@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:58486] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/E1-17254-F9936F64 for ; Sun, 23 Sep 2007 06:02:08 -0400 Received: from [10.1.3.7] ([10.1.3.7]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Sun, 23 Sep 2007 12:05:50 +0200 Message-ID: <46F6399D.4040406@zend.com> Date: Sun, 23 Sep 2007 12:02:05 +0200 User-Agent: Icedove 1.5.0.8 (X11/20061129) MIME-Version: 1.0 To: internals@lists.php.net Content-Type: multipart/mixed; boundary="------------080908070104040706020801" X-OriginalArrivalTime: 23 Sep 2007 10:05:50.0848 (UTC) FILETIME=[51F2F800:01C7FDC9] Subject: bug in odbc extension http://bugs.php.net/bug.php?id=40695 From: alexandra@zend.com ("Alexandra S.") --------------080908070104040706020801 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I am attaching here a small patch for this bug. The original error for the reproduction script in this bug was: *Warning*: odbc_execute() [function.odbc-execute ]: SQL error: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect , SQL state 07001 in SQLExecute in *C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\odbc2.php* on line *33 This is not the right error. since we did not check the return codes from SQLDescribeParam php_odbc.php:1000 we did not see that the real error is: **Warning*: odbc_execute() [function.odbc-execute ]: SQL error: [Microsoft][ODBC Driver Manager] Driver does not support this function, SQL state IM001 in hello - SQL_ERROR in *C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\odbc2.php* on line *33 Please review the patch Alexandra Shpindovsky --------------080908070104040706020801 Content-Type: text/plain; name="patch2.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch2.txt" --- php_odbc.c 2007-03-13 02:04:38.000000000 +0200 +++ php_odbc.c 2007-09-20 10:13:00.000000000 +0200 @@ -997,8 +997,21 @@ RETURN_FALSE; } - SQLDescribeParam(result->stmt, (UWORD)i, &sqltype, &precision, + rc = SQLDescribeParam(result->stmt, (UWORD)i, &sqltype, &precision, &scale, &nullable); + + if (rc == SQL_INVALID_HANDLE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLDescribeParam error 'Invalid Handle'"); + efree(result); + RETURN_FALSE; + } + + if (rc == SQL_ERROR) { + odbc_sql_error(result->conn_ptr, result->stmt, "SQLDescribeParam"); + efree(result); + RETURN_FALSE; + } + params[i-1].vallen = Z_STRLEN_PP(tmp); params[i-1].fp = -1; @@ -1048,6 +1061,17 @@ ctype, sqltype, precision, scale, (void *)params[i-1].fp, 0, ¶ms[i-1].vallen); + if (rc == SQL_INVALID_HANDLE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLBindParameter error 'Invalid Handle'"); + efree(result); + RETURN_FALSE; + } + + if (rc == SQL_ERROR) { + odbc_sql_error(result->conn_ptr, result->stmt, "SQLBindParameter"); + efree(result); + RETURN_FALSE; + } } else { #ifdef HAVE_DBMAKER precision = params[i-1].vallen; @@ -1060,6 +1084,18 @@ ctype, sqltype, precision, scale, Z_STRVAL_PP(tmp), 0, ¶ms[i-1].vallen); + + if (rc == SQL_INVALID_HANDLE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SQLBindParameter error 'Invalid Handle'"); + efree(result); + RETURN_FALSE; + } + + if (rc == SQL_ERROR) { + odbc_sql_error(result->conn_ptr, result->stmt, "SQLBindParameter"); + efree(result); + RETURN_FALSE; + } } zend_hash_move_forward(Z_ARRVAL_PP(pv_param_arr)); } /* }}} */ --------------080908070104040706020801--