]> granicus.if.org Git - php/commitdiff
use snprintf()
authorAntony Dovgal <tony2001@php.net>
Thu, 18 Jan 2007 15:54:45 +0000 (15:54 +0000)
committerAntony Dovgal <tony2001@php.net>
Thu, 18 Jan 2007 15:54:45 +0000 (15:54 +0000)
ext/pdo_firebird/firebird_driver.c

index 803192545d01b616999c321f8c6aafb98ce5cf9f..7e65a880a7a5d209078779970e7d7a7e5a0e7953 100644 (file)
@@ -602,6 +602,8 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
                { "role", NULL, 0 }
        };
        int i, ret = 0;
+       short buf_len = 256, dpb_len;
+
        pdo_firebird_db_handle *H = dbh->driver_data = pecalloc(1,sizeof(*H),dbh->is_persistent);
 
        php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, 3);
@@ -616,9 +618,11 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
                
                /* loop through all the provided arguments and set dpb fields accordingly */
                for (i = 0; i < sizeof(dpb_flags); ++i) {
-                       if (dpb_values[i]) {
-                               dpb += sprintf(dpb, "%c%c%s", dpb_flags[i], (unsigned char)strlen(dpb_values[i]),
+                       if (dpb_values[i] && buf_len > 0) {
+                               dpb_len = snprintf(dpb, buf_len, "%c%c%s", dpb_flags[i], (unsigned char)strlen(dpb_values[i]),
                                        dpb_values[i]);
+                               dpb += dpb_len;
+                               buf_len -= dpb_len;
                        }
                }