Skip to content

odbc_connect does not pass authentication information to the driver under certain conditions #12296

Closed
@SakiTakamachi

Description

@SakiTakamachi

Description

These are the problems that I found out while investigating various things because #12295, which is a fix PR for #12251, did not work properly.

  1. If we pass an empty string for the password, the authentication information will not be passed in DSN when direct.
odbc_connect('Driver=FreeTDS;Server=mssql-server;Port=1433;Database=test', 'test_user2', ''); // my env

gdb

2138				rc = SQLDriverConnect((*conn)->hdbc, NULL, (SQLCHAR *) ldb, strlen(ldb), dsnbuf, sizeof(dsnbuf) - 1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
(gdb) p ldb
$1 = 0x7f45d265b240 "Driver=FreeTDS;Server=mssql-server;Port=1433;Database=test"
  1. If only one of uid or pwd is included in the dsn, the other will not be included in the built dsn.
odbc_connect('Driver=FreeTDS;Server=mssql-server;Port=1433;Database=test;uid=test_user', 'test_user', 'p@ssw0rd'); // my env

gdb

2138				rc = SQLDriverConnect((*conn)->hdbc, NULL, (SQLCHAR *) ldb, strlen(ldb), dsnbuf, sizeof(dsnbuf) - 1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
(gdb) p ldb
$1 = 0x7f089467f000 "Driver=FreeTDS;Server=mssql-server;Port=1433;Database=test;uid=test_user"

PHP Version

PHP8.2+

Operating System

Ubuntu22.04 (docker image)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions