Bug #68577 [NEW]: 'batchsize' parameter and negative values
| From: | horton at tm43 dot cf | Date: | Tue, 09 Dec 2014 16:12:10 +0000 |
| Subject: | Bug #68577 [NEW]: 'batchsize' parameter and negative values | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-188978@lists.php.net to get a copy of this message | ||
From: horton at tm43 dot cf
Operating system:
PHP version: Irrelevant
Package: MSSQL related
Bug Type: Bug
Bug description:'batchsize' parameter and negative values
Description:
------------
To make it extremely short: I believe a line within the
_mssql_fetch_batch() function (in ext/mssql/php_mssql.c) should be
changed (or the documentation).
Original:
if ( i < result->batchsize || result->batchsize == 0 )
Patched:
if ( i < result->batchsize || result->batchsize <= 0 )
In the original version, if 'i' is less than 'result->batchsize' OR
'result->batchsize' is equal to '0', then the next record is copied to
the buffer and 'i' is incremented. This means, following the
documentation and the most likely intention of the author (and the
IF-clause), the 'batchsize' parameter of (for example) the
'mssql_query()' function is either a positive integer greater than zero,
specifying the number of records to be fetched and stored within the
buffer OR ANY other value, meaning that all records are fetched and
stored within the buffer.
But the source code only checks the latter case by comparing 'batchsize'
to '0', where as it should perform the comparison with '<= 0', to
include negative numbers, which can be supplied by the caller (there is
no check performed anywhere against this case!). Otherwise, by supplying
a negative value, the loop is left immediately in the first run, which
might not be the intention of the author.
Thing is, I stumbled upon this oddity by inspecting the source code and
cannot test it, since I have neither a Windows PC nor a MSSQL server to
connect to, so this should be verified by someone, who does. Though I
expect no problems at all, when patching this line AND modify slightly
the documentation, that 0 or any negative value for 'batchsize' leads to
fetching all records..
--
Edit bug report at https://bugs.php.net/bug.php?id=68577&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68577&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68577&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68577&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68577&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68577&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68577&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68577&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68577&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68577&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68577&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68577&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68577&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68577&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68577&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68577&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68577&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68577&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68577&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68577&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68577&r=mysqlcfg