php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14436 odbc_fetch_row crashes PHP with aliased table
Submitted: 2001-12-11 16:37 UTC Modified: 2002-04-23 16:11 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nick at advalue dot com Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.2.0 OS: WinNT
Private report: No CVE-ID: None
 [2001-12-11 16:37 UTC] nick at advalue dot com
When using odbc_fetch_row() with specific queries, the PHP module attempts to write to a NULL pointer, which crashes Apache.

A query must do the following to cause the problem:

1) The query must use only one table (i.e., no joins).

2) The table's name must be aliased (e.g., "FROM MyTable MyAlias").

3) The SELECT clause must use the table's alias with at least one column (e.g., "SELECT MyAlias.ID").

The following script can be used to reproduce the bug.

<?php
$Connection = odbc_pconnect('db','user','pass');
$Result = odbc_exec($Connection,'SELECT MyAlias.ID FROM MyTable MyAlias');

while (odbc_fetch_row($Result))
{
echo 'Row<BR>';
}
?>

If I expand the query to do a join with another table, it will work fine. It also works fine if I remove the table alias from the SELECT clause. However, the queries I need to use are dynamically generated and it is much simpler if I can alias the table names without worrying about how many tables are being referenced.

I'm using PHP 4.0.6 (binary download from PHP.net) on Windows NT 4.0 Workstation with Apache 1.3.22. I'm connecting via ODBC to a remote Oracle 9i database.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-13 15:04 UTC] nick at advalue dot com
Bug has been reproduced in PHP 4.1.0, so I've updated the PHP Version number.
 [2002-04-23 16:11 UTC] nick at advalue dot com
Bug is fixed in 4.2.0.
 [2002-06-10 07:14 UTC] kolenchuk at yahoo dot com
Bug is not fixed in php 4.2.1
sql like this "SELECT a.kod, a.name FROM t.kprep a WHERE a.kod='002200'" crashed PHP.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 11 03:01:29 2024 UTC