From fac08422104f2966edc8ba4583f2134211d3d5c9 Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Thu, 21 Sep 2017 12:58:18 -0700 Subject: [PATCH 1/5] Added install requirements to readme --- ODBC 17 binaries preview/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ODBC 17 binaries preview/README.md b/ODBC 17 binaries preview/README.md index e019ff8c..f733071b 100644 --- a/ODBC 17 binaries preview/README.md +++ b/ODBC 17 binaries preview/README.md @@ -1 +1,3 @@ -The ODBC driver 17 preview binaries in this directory are required in order to use Always Encrypted (AE) functionality. Please note that these drivers should be considered to be preview versions -- they should not be used in production and are not supported by Microsoft. They will be replaced upon the official release of ODBC driver 17. \ No newline at end of file +The ODBC driver 17 preview binaries in this directory are required in order to use Always Encrypted (AE) functionality. Please note that these drivers should be considered to be preview versions -- they should not be used in production and are not supported by Microsoft. They will be replaced upon the official release of ODBC driver 17. + +On Windows, the ODBC 17 preview binaries require the Visual C/C++ 2013 runtime libraries installed separately. These are installed with the [Visual Studio C++ 2013 Redistributable](https://www.microsoft.com/en-ca/download/details.aspx?id=40784) or with the [SQL Server command line utilities](https://www.microsoft.com/en-ca/download/details.aspx?id=53591). \ No newline at end of file From 57a41d71e9d6084c474d58e46d98d6894a81066f Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Thu, 21 Sep 2017 15:59:54 -0700 Subject: [PATCH 2/5] fix PDO::quote api when input string contain a NUL ASCII character --- source/pdo_sqlsrv/pdo_dbh.cpp | 4 +-- .../pdo_sqlsrv/pdo_538_quote_nul.phpt | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/functional/pdo_sqlsrv/pdo_538_quote_nul.phpt diff --git a/source/pdo_sqlsrv/pdo_dbh.cpp b/source/pdo_sqlsrv/pdo_dbh.cpp index 80a99b7f..c0a7ea4f 100644 --- a/source/pdo_sqlsrv/pdo_dbh.cpp +++ b/source/pdo_sqlsrv/pdo_dbh.cpp @@ -1463,7 +1463,7 @@ int pdo_sqlsrv_dbh_quote( _Inout_ pdo_dbh_t* dbh, _In_reads_(unquoted_len) const if ( encoding == SQLSRV_ENCODING_UTF8 ) { quotes_needed = 3; } - for ( size_t index = 0; index < unquoted_len && unquoted[ index ] != '\0'; ++index ) { + for ( size_t index = 0; index < unquoted_len; ++index ) { if ( unquoted[ index ] == '\'' ) { ++quotes_needed; } @@ -1480,7 +1480,7 @@ int pdo_sqlsrv_dbh_quote( _Inout_ pdo_dbh_t* dbh, _In_reads_(unquoted_len) const // insert initial quote ( *quoted )[ out_current++ ] = '\''; - for ( size_t index = 0; index < unquoted_len && unquoted[ index ] != '\0'; ++index ) { + for ( size_t index = 0; index < unquoted_len; ++index ) { if ( unquoted[ index ] == '\'' ) { ( *quoted )[ out_current++ ] = '\''; ( *quoted )[ out_current++ ] = '\''; diff --git a/test/functional/pdo_sqlsrv/pdo_538_quote_nul.phpt b/test/functional/pdo_sqlsrv/pdo_538_quote_nul.phpt new file mode 100644 index 00000000..91ca72be --- /dev/null +++ b/test/functional/pdo_sqlsrv/pdo_538_quote_nul.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test the PDO::quote() method. +--SKIPIF-- + +--FILE-- +setAttribute( PDO::SQLSRV_ATTR_DIRECT_QUERY, PDO::SQLSRV_ENCODING_SYSTEM ); + + $str = "XX\0XX"; + + print("Original: " . str_replace("\0", "{NUL}", $str) . "\n"); + $str = $connection->quote($str); + print("Quoted: " . str_replace("\0", "{NUL}", $str) . "\n"); +} + +catch( PDOException $e ) { + die("Connection error: " . $e->getMessage()); +} +?> + +--EXPECT-- +Original: XX{NUL}XX +Quoted: 'XX{NUL}XX' \ No newline at end of file From 5ac1c7353300722bb8e1bd123bff6524ffa54bd8 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Tue, 26 Sep 2017 11:33:56 -0700 Subject: [PATCH 3/5] add description to test --- test/functional/pdo_sqlsrv/pdo_538_quote_nul.phpt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/functional/pdo_sqlsrv/pdo_538_quote_nul.phpt b/test/functional/pdo_sqlsrv/pdo_538_quote_nul.phpt index 91ca72be..a636c7fc 100644 --- a/test/functional/pdo_sqlsrv/pdo_538_quote_nul.phpt +++ b/test/functional/pdo_sqlsrv/pdo_538_quote_nul.phpt @@ -1,5 +1,5 @@ --TEST-- -Test the PDO::quote() method. +Test the PDO::quote() method with a string containing '\0' character --SKIPIF-- --FILE-- @@ -10,7 +10,6 @@ require_once 'MsCommon.inc'; try { $connection = connect(); - //$connection->setAttribute( PDO::SQLSRV_ATTR_DIRECT_QUERY, PDO::SQLSRV_ENCODING_SYSTEM ); $str = "XX\0XX"; From 2f8ba00595cc0677f46a89b1ee51bfab754a2d19 Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Tue, 26 Sep 2017 11:58:09 -0700 Subject: [PATCH 4/5] Update README.md --- ODBC 17 binaries preview/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ODBC 17 binaries preview/README.md b/ODBC 17 binaries preview/README.md index f733071b..feca90a1 100644 --- a/ODBC 17 binaries preview/README.md +++ b/ODBC 17 binaries preview/README.md @@ -1,3 +1,5 @@ The ODBC driver 17 preview binaries in this directory are required in order to use Always Encrypted (AE) functionality. Please note that these drivers should be considered to be preview versions -- they should not be used in production and are not supported by Microsoft. They will be replaced upon the official release of ODBC driver 17. -On Windows, the ODBC 17 preview binaries require the Visual C/C++ 2013 runtime libraries installed separately. These are installed with the [Visual Studio C++ 2013 Redistributable](https://www.microsoft.com/en-ca/download/details.aspx?id=40784) or with the [SQL Server command line utilities](https://www.microsoft.com/en-ca/download/details.aspx?id=53591). \ No newline at end of file +On Windows, the ODBC 17 preview binaries require the Visual C/C++ 2013 runtime libraries installed separately. These are installed with the [Visual Studio C++ 2013 Redistributable](https://www.microsoft.com/en-ca/download/details.aspx?id=40784) or with the [SQL Server command line utilities](https://www.microsoft.com/en-ca/download/details.aspx?id=53591). Once you have these, simply run the msi to install. + +For instructions on installing the binaries on Linux platforms, please see [this page](https://github.com/Microsoft/msphpsql/wiki/Install-and-configuration#odbc-17-linux-installation). From 426a16c0ce132726e78814b8db3c4d6e9395f26f Mon Sep 17 00:00:00 2001 From: David Puglielli Date: Thu, 28 Sep 2017 17:18:26 -0700 Subject: [PATCH 5/5] Update README.md --- ODBC 17 binaries preview/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ODBC 17 binaries preview/README.md b/ODBC 17 binaries preview/README.md index dad87aea..c1a0a405 100644 --- a/ODBC 17 binaries preview/README.md +++ b/ODBC 17 binaries preview/README.md @@ -1,5 +1,5 @@ -The ODBC driver 17 preview binaries in this directory are required in order to use Always Encrypted (AE) functionality. Please note that these drivers should be considered to be preview versions -- they should not be used in production and are not supported by Microsoft. They will be replaced upon the official release of ODBC driver 17. +The ODBC driver 17 preview binaries in this directory are required in order to use Always Encrypted functionality. Please note that these drivers should be considered to be preview versions -- they should not be used in production and are not supported by Microsoft. They will be replaced upon the official release of ODBC driver 17. On Windows, the ODBC 17 preview binaries require the Visual C/C++ 2013 runtime libraries installed separately. These are installed with the [Visual Studio C++ 2013 Redistributable](https://www.microsoft.com/en-ca/download/details.aspx?id=40784) or with the [SQL Server command line utilities](https://www.microsoft.com/en-ca/download/details.aspx?id=53591). Once you have these, simply run the msi to install.