Skip to content

Commit 3c71354

Browse files
committed
Made uid and pwd of odbc_connect and odbc_pconnect nullable.
1 parent 7bb69d0 commit 3c71354

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

ext/odbc/odbc.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,12 @@ function odbc_free_result($statement): bool {}
382382
/**
383383
* @return resource|false
384384
*/
385-
function odbc_connect(string $dsn, string $user, #[\SensitiveParameter] string $password, int $cursor_option = SQL_CUR_USE_DRIVER) {}
385+
function odbc_connect(string $dsn, ?string $user = null, #[\SensitiveParameter] ?string $password = null, int $cursor_option = SQL_CUR_USE_DRIVER) {}
386386

387387
/**
388388
* @return resource|false
389389
*/
390-
function odbc_pconnect(string $dsn, string $user, #[\SensitiveParameter] string $password, int $cursor_option = SQL_CUR_USE_DRIVER) {}
390+
function odbc_pconnect(string $dsn, ?string $user = null, #[\SensitiveParameter] ?string $password = null, int $cursor_option = SQL_CUR_USE_DRIVER) {}
391391

392392
/** @param resource $odbc */
393393
function odbc_close($odbc): void {}

ext/odbc/odbc_arginfo.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/odbc/php_odbc.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,8 +2098,8 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
20982098

20992099
size_t db_len = strlen(db);
21002100
char *db_end = db + db_len;
2101-
bool use_uid_arg = !php_memnistr(db, "uid=", strlen("uid="), db_end);
2102-
bool use_pwd_arg = !php_memnistr(db, "pwd=", strlen("pwd="), db_end);
2101+
bool use_uid_arg = uid != NULL && !php_memnistr(db, "uid=", strlen("uid="), db_end);
2102+
bool use_pwd_arg = pwd != NULL && !php_memnistr(db, "pwd=", strlen("pwd="), db_end);
21032103

21042104
/* Force UID and PWD to be set in the DSN */
21052105
if (use_uid_arg || use_pwd_arg) {
@@ -2190,18 +2190,19 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
21902190
/* {{{ odbc_do_connect */
21912191
void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
21922192
{
2193-
char *db, *uid, *pwd;
2193+
char *db, *uid=NULL, *pwd=NULL;
21942194
size_t db_len, uid_len, pwd_len;
21952195
zend_long pv_opt = SQL_CUR_DEFAULT;
21962196
odbc_connection *db_conn;
21972197
int cur_opt;
21982198

2199-
/* Now an optional 4th parameter specifying the cursor type
2200-
* defaulting to the cursors default
2201-
*/
2202-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|l", &db, &db_len, &uid, &uid_len, &pwd, &pwd_len, &pv_opt) == FAILURE) {
2203-
RETURN_THROWS();
2204-
}
2199+
ZEND_PARSE_PARAMETERS_START(1, 4)
2200+
Z_PARAM_STRING(db, db_len)
2201+
Z_PARAM_OPTIONAL
2202+
Z_PARAM_STRING_OR_NULL(uid, uid_len)
2203+
Z_PARAM_STRING_OR_NULL(pwd, pwd_len)
2204+
Z_PARAM_LONG(pv_opt)
2205+
ZEND_PARSE_PARAMETERS_END();
22052206

22062207
cur_opt = pv_opt;
22072208

0 commit comments

Comments
 (0)