abies Sat Aug 16 15:48:32 2003 EDT
Modified files:
/php-src/ext/interbase interbase.c
Log:
Always fill entire buffer in ibase_blob_get()
Index: php-src/ext/interbase/interbase.c
diff -u php-src/ext/interbase/interbase.c:1.147 php-src/ext/interbase/interbase.c:1.148
--- php-src/ext/interbase/interbase.c:1.147 Sat Aug 16 12:09:24 2003
+++ php-src/ext/interbase/interbase.c Sat Aug 16 15:48:32 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: interbase.c,v 1.147 2003/08/16 16:09:24 abies Exp $ */
+/* $Id: interbase.c,v 1.148 2003/08/16 19:48:32 abies Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -699,7 +699,7 @@
php_info_print_table_start();
php_info_print_table_row(2, "Interbase Support", "enabled");
- php_info_print_table_row(2, "Revision", "$Revision: 1.147 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.148 $");
#ifdef COMPILE_DL_INTERBASE
php_info_print_table_row(2, "Dynamic Module", "Yes");
#endif
@@ -3364,7 +3364,7 @@
for (rem_cnt = Z_STRLEN_PP(string_arg); rem_cnt > 0; rem_cnt -= chunk_size) {
- chunk_size = rem_cnt > USHRT_MAX ? USHRT_MAX : rem_cnt;
+ chunk_size = rem_cnt > USHRT_MAX ? USHRT_MAX : (unsigned short)rem_cnt;
if (isc_put_segment(IB_STATUS, &ib_blob->bl_handle, chunk_size,
&Z_STRVAL_PP(string_arg)[put_cnt] )) {
_php_ibase_error(TSRMLS_C);
@@ -3381,9 +3381,8 @@
PHP_FUNCTION(ibase_blob_get)
{
zval **blob_arg, **len_arg;
- int stat;
+ ISC_STATUS stat;
char *bl_data;
- unsigned short seg_len;
unsigned long max_len, cur_len;
ibase_blob_handle *ib_blob;
@@ -3404,20 +3403,20 @@
bl_data = emalloc(max_len + 1);
- for (cur_len = stat = 0; stat == 0;) {
- unsigned short next_chunk_size = (max_len-cur_len) > USHRT_MAX
? USHRT_MAX : (max_len-cur_len);
+ for (cur_len = stat = 0; stat == 0 || stat == isc_segment; ) {
+ unsigned short seg_len, chunk_size = (max_len-cur_len) >
USHRT_MAX ? USHRT_MAX : (unsigned short)(max_len-cur_len);
+
+ stat = isc_get_segment(IB_STATUS, &ib_blob->bl_handle,
&seg_len, chunk_size, &bl_data[cur_len]);
- stat = isc_get_segment(IB_STATUS, &ib_blob->bl_handle,
&seg_len, next_chunk_size, &bl_data[cur_len]);
cur_len += seg_len;
- if (cur_len > max_len) { /* never!*/
- efree(bl_data);
- _php_ibase_module_error("PHP module internal error");
- RETURN_FALSE;
+
+ if (cur_len == max_len) {
+ break;
}
}
bl_data[cur_len] = '\0';
- if (IB_STATUS[0] && (IB_STATUS[1] != isc_segstr_eof && IB_STATUS[1] !=
isc_segment)) {
+ if (IB_STATUS[0] == 1 && (stat != 0 && stat != isc_segstr_eof && stat
!= isc_segment)) {
efree(bl_data);
_php_ibase_error(TSRMLS_C);
RETURN_FALSE;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php