svn: /php/php-src/branches/PHP_5_3/ext/sybase_ct/ php_sybase_ct.c
| From: | Timm Friebe | Date: | Wed, 16 Jun 2010 09:49:25 +0000 |
| Subject: | svn: /php/php-src/branches/PHP_5_3/ext/sybase_ct/ php_sybase_ct.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-62899@lists.php.net to get a copy of this message | ||
thekid Wed, 16 Jun 2010 09:49:25 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=300491
Log:
- MFT: Fixed segmentation fault when reading rows
# Problem surfaces when using FreeTDS, ASE 12.5 and reading text fields
# with NULL values. This is essentially a workaround for a bug in Free-
# TDS which is not setting the NULL indicators correctly, but provides
# a protection against possible segfaults if any other driver ever does
# this again:-)
Changed paths:
U php/php-src/branches/PHP_5_3/ext/sybase_ct/php_sybase_ct.c
Modified: php/php-src/branches/PHP_5_3/ext/sybase_ct/php_sybase_ct.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/sybase_ct/php_sybase_ct.c 2010-06-16 09:34:11 UTC (rev 300490)
+++ php/php-src/branches/PHP_5_3/ext/sybase_ct/php_sybase_ct.c 2010-06-16 09:49:25 UTC (rev 300491)
@@ -1248,8 +1248,17 @@
}
default: {
- /* This indicates anything else, return it as string */
- ZVAL_STRINGL(&result->data[i][j], result->tmp_buffer[j], result->lengths[j]- 1,
1);
+ /* This indicates anything else, return it as string
+ * FreeTDS doesn't correctly set result->indicators[j] correctly
+ * for NULL fields in some version in conjunction with ASE 12.5
+ * but instead sets result->lengths[j] to 0, which would lead to
+ * a negative memory allocation (and thus a segfault).
+ */
+ if (result->lengths[j] < 1) {
+ ZVAL_NULL(&result->data[i][j]);
+ } else {
+ ZVAL_STRINGL(&result->data[i][j], result->tmp_buffer[j], result->lengths[j]- 1,
1);
+ }
break;
}
}