Skip to content

Commit

Permalink
Fix for nts
Browse files Browse the repository at this point in the history
  • Loading branch information
absci committed Jul 27, 2022
1 parent ae1f808 commit 6293a91
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ jobs:
for f in pdo_sqlsrv/*.diff; do ls $f 2>/dev/null; cat $f 2>/dev/null; echo ''; done || true
python output.py
ls -l *.xml
more *.diff | cat
cat *.diff
displayName: 'Processing test results'
- task: PublishTestResults@2
Expand Down
2 changes: 1 addition & 1 deletion source/pdo_sqlsrv/pdo_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ PHP_RSHUTDOWN_FUNCTION(pdo_sqlsrv)
{
// SQLSRV_UNUSED( module_number );
// SQLSRV_UNUSED( type );
#ifdef _WIN32
#if defined(_WIN32) && !defined(ZTS)
for (size_t current_token = 0; current_token < PDO_SQLSRV_G(access_tokens_size); current_token++) {
if (PDO_SQLSRV_G(access_tokens)[current_token]) {
memset(PDO_SQLSRV_G(access_tokens)[current_token]->data, 0, PDO_SQLSRV_G(access_tokens)[current_token]->dataSize);
Expand Down
13 changes: 7 additions & 6 deletions source/shared/core_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,13 @@ sqlsrv_conn* core_sqlsrv_connect( _In_ sqlsrv_context& henv_cp, _In_ sqlsrv_cont
}
}

#ifdef ZTS
// time to free the access token, if not null
if (conn->azure_ad_access_token) {
memset(conn->azure_ad_access_token->data, 0, conn->azure_ad_access_token->dataSize); // clear the memory
conn->azure_ad_access_token.reset();
}

#endif
CHECK_SQL_ERROR( r, conn ) {
throw core::CoreException();
}
Expand Down Expand Up @@ -1165,7 +1166,7 @@ size_t core_str_zval_is_true(_Inout_ zval* value_z)
return 0; // false
}

#ifdef _WIN32
#if defined(_WIN32) && !defined(ZTS)
ACCESSTOKEN** get_access_tokens() {
#ifdef PDO_SQLSRV
return PDO_SQLSRV_G(access_tokens);
Expand Down Expand Up @@ -1204,7 +1205,7 @@ void access_token_set_func::func(_In_ connection_option const* option, _In_ zval
// similar to a UCS-2 string containing only ASCII characters
//
// See https://docs.microsoft.com/sql/connect/odbc/using-azure-active-directory#authenticating-with-an-access-token
#ifdef _WIN32
#if defined(_WIN32) && !defined(ZTS)
size_t next_token_position = 0;
bool same_token_used = false;
#ifdef PDO_SQLSRV
Expand Down Expand Up @@ -1249,14 +1250,14 @@ void access_token_set_func::func(_In_ connection_option const* option, _In_ zval
// Save the pointer because SQLDriverConnect() will use it to make connection to the server
conn->azure_ad_access_token = pAccToken;
accToken.transferred();
#ifdef _WIN32
#if defined(_WIN32) && !defined(ZTS)
if (!same_token_used) {
next_token_position = access_tokens_size;
access_tokens_size++;
#ifdef PDO_SQLSRV
PDO_SQLSRV_G(access_tokens) = reinterpret_cast<ACCESSTOKEN**>(sqlsrv_realloc(PDO_SQLSRV_G(access_tokens), access_tokens_size * sizeof(ACCESSTOKEN)));
PDO_SQLSRV_G(access_tokens) = reinterpret_cast<ACCESSTOKEN**>(sqlsrv_realloc(PDO_SQLSRV_G(access_tokens), access_tokens_size * sizeof(ACCESSTOKEN*)));
#elif SQLSRV
SQLSRV_G(access_tokens) = reinterpret_cast<ACCESSTOKEN**>(sqlsrv_realloc(SQLSRV_G(access_tokens), access_tokens_size * sizeof(ACCESSTOKEN)));
SQLSRV_G(access_tokens) = reinterpret_cast<ACCESSTOKEN**>(sqlsrv_realloc(SQLSRV_G(access_tokens), access_tokens_size * sizeof(ACCESSTOKEN*)));
#endif
}
get_access_tokens()[next_token_position] = conn->azure_ad_access_token;
Expand Down
2 changes: 1 addition & 1 deletion source/sqlsrv/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ PHP_RSHUTDOWN_FUNCTION(sqlsrv)
// SQLSRV_UNUSED( type );

LOG_FUNCTION( "PHP_RSHUTDOWN for php_sqlsrv" );
#ifdef _WIN32
#if defined(_WIN32) && !defined(ZTS)
for (size_t current_token = 0; current_token < SQLSRV_G(access_tokens_size); current_token++) {
if (SQLSRV_G(access_tokens)[current_token]) {
memset(SQLSRV_G(access_tokens)[current_token]->data, 0, SQLSRV_G(access_tokens)[current_token]->dataSize);
Expand Down

0 comments on commit 6293a91

Please sign in to comment.