Skip to content

Commit b64de4e

Browse files
committed
ext/odbc: rename function now that it gets the exact length rather than an estimate
1 parent ff708a4 commit b64de4e

5 files changed

Lines changed: 16 additions & 16 deletions

File tree

ext/odbc/odbc_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ PHP_FUNCTION(odbc_connection_string_quote)
5757
Z_PARAM_STR(str)
5858
ZEND_PARSE_PARAMETERS_END();
5959

60-
size_t new_size = php_odbc_connstr_estimate_quote_length(ZSTR_VAL(str));
60+
size_t new_size = php_odbc_connstr_get_quoted_length(ZSTR_VAL(str));
6161
zend_string *new_string = zend_string_alloc(new_size, 0);
6262
php_odbc_connstr_quote(ZSTR_VAL(new_string), ZSTR_VAL(str), new_size);
6363
/* reset length */

ext/odbc/php_odbc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,9 +1951,9 @@ bool odbc_sqlconnect(zval *zv, char *db, char *uid, char *pwd, int cur_opt, bool
19511951
if (use_uid_arg) {
19521952
should_quote_uid = !php_odbc_connstr_is_quoted(uid) && php_odbc_connstr_should_quote(uid);
19531953
if (should_quote_uid) {
1954-
size_t estimated_length = php_odbc_connstr_estimate_quote_length(uid);
1955-
uid_quoted = emalloc(estimated_length);
1956-
php_odbc_connstr_quote(uid_quoted, uid, estimated_length);
1954+
size_t quoted_length = php_odbc_connstr_get_quoted_length(uid);
1955+
uid_quoted = emalloc(quoted_length);
1956+
php_odbc_connstr_quote(uid_quoted, uid, quoted_length);
19571957
} else {
19581958
uid_quoted = uid;
19591959
}
@@ -1966,9 +1966,9 @@ bool odbc_sqlconnect(zval *zv, char *db, char *uid, char *pwd, int cur_opt, bool
19661966
if (use_pwd_arg) {
19671967
should_quote_pwd = !php_odbc_connstr_is_quoted(pwd) && php_odbc_connstr_should_quote(pwd);
19681968
if (should_quote_pwd) {
1969-
size_t estimated_length = php_odbc_connstr_estimate_quote_length(pwd);
1970-
pwd_quoted = emalloc(estimated_length);
1971-
php_odbc_connstr_quote(pwd_quoted, pwd, estimated_length);
1969+
size_t quoted_length = php_odbc_connstr_get_quoted_length(pwd);
1970+
pwd_quoted = emalloc(quoted_length);
1971+
php_odbc_connstr_quote(pwd_quoted, pwd, quoted_length);
19721972
} else {
19731973
pwd_quoted = pwd;
19741974
}

ext/pdo_odbc/odbc_driver.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,9 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
548548
if (use_uid_arg) {
549549
should_quote_uid = !php_odbc_connstr_is_quoted(dbh->username) && php_odbc_connstr_should_quote(dbh->username);
550550
if (should_quote_uid) {
551-
size_t estimated_length = php_odbc_connstr_estimate_quote_length(dbh->username);
552-
uid = emalloc(estimated_length);
553-
php_odbc_connstr_quote(uid, dbh->username, estimated_length);
551+
size_t quoted_length = php_odbc_connstr_get_quoted_length(dbh->username);
552+
uid = emalloc(quoted_length);
553+
php_odbc_connstr_quote(uid, dbh->username, quoted_length);
554554
} else {
555555
uid = dbh->username;
556556
}
@@ -565,9 +565,9 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
565565
if (use_pwd_arg) {
566566
should_quote_pwd = !php_odbc_connstr_is_quoted(dbh->password) && php_odbc_connstr_should_quote(dbh->password);
567567
if (should_quote_pwd) {
568-
size_t estimated_length = php_odbc_connstr_estimate_quote_length(dbh->password);
569-
pwd = emalloc(estimated_length);
570-
php_odbc_connstr_quote(pwd, dbh->password, estimated_length);
568+
size_t quoted_length = php_odbc_connstr_get_quoted_length(dbh->password);
569+
pwd = emalloc(quoted_length);
570+
php_odbc_connstr_quote(pwd, dbh->password, quoted_length);
571571
} else {
572572
pwd = dbh->password;
573573
}

main/php_odbc_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ PHPAPI bool php_odbc_connstr_should_quote(const char *str)
7171
}
7272

7373
/**
74-
* Estimates the worst-case scenario for a quoted version of a string's size.
74+
* Gets the length of a string after it has been quoted.
7575
*/
76-
PHPAPI size_t php_odbc_connstr_estimate_quote_length(const char *in_str)
76+
PHPAPI size_t php_odbc_connstr_get_quoted_length(const char *in_str)
7777
{
7878
/* Start with including the quotes ({}) and the null terminator */
7979
size_t size = 3;

main/php_odbc_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616

1717
PHPAPI bool php_odbc_connstr_is_quoted(const char *str);
1818
PHPAPI bool php_odbc_connstr_should_quote(const char *str);
19-
PHPAPI size_t php_odbc_connstr_estimate_quote_length(const char *in_str);
19+
PHPAPI size_t php_odbc_connstr_get_quoted_length(const char *in_str);
2020
PHPAPI size_t php_odbc_connstr_quote(char *out_str, const char *in_str, size_t out_str_size);

0 commit comments

Comments
 (0)