Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions source/db2AllocConnHdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,18 @@ DB2ConnEntry* findconnEntry(DB2ConnEntry* start, const char* srvname, const char
DB2ConnEntry* step = NULL;
db2Debug2(" > findconnEntry");
for (step = start; step != NULL; step = step->right){
/* NULL-safe comparison for JWT auth where user may be NULL */
int srv_match = (step->srvname && srvname) ? strcmp(step->srvname, srvname) == 0 : step->srvname == srvname;
int uid_match = (step->uid && user) ? strcmp(step->uid, user) == 0 : step->uid == user;
/* NULL-safe comparison for JWT auth where user may be NULL or empty */
/* Treat NULL and empty string as equivalent */
int srv_null_or_empty = (!step->srvname || step->srvname[0] == '\0');
int srvname_null_or_empty = (!srvname || srvname[0] == '\0');
int srv_match = (srv_null_or_empty && srvname_null_or_empty) ||
(!srv_null_or_empty && !srvname_null_or_empty && strcmp(step->srvname, srvname) == 0);

int uid_null_or_empty = (!step->uid || step->uid[0] == '\0');
int user_null_or_empty = (!user || user[0] == '\0');
int uid_match = (uid_null_or_empty && user_null_or_empty) ||
(!uid_null_or_empty && !user_null_or_empty && strcmp(step->uid, user) == 0);

if (srv_match && uid_match) {
break;
}
Expand Down
4 changes: 4 additions & 0 deletions source/db2BeginForeignModify.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ DB2FdwState* deserializePlanData (List* list) {
state->password = deserializeString (lfirst (cell));
cell = list_next (list,cell);

/* jwt_token */
state->jwt_token = deserializeString (lfirst (cell));
cell = list_next (list,cell);

/* nls_lang */
state->nls_lang = deserializeString (lfirst (cell));
cell = list_next (list,cell);
Expand Down
2 changes: 2 additions & 0 deletions source/db2PlanForeignModify.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ List* serializePlanData (DB2FdwState* fdwState) {
result = lappend (result, serializeString (fdwState->user));
/* password */
result = lappend (result, serializeString (fdwState->password));
/* jwt_token */
result = lappend (result, serializeString (fdwState->jwt_token));
/* nls_lang */
result = lappend (result, serializeString (fdwState->nls_lang));
/* query */
Expand Down
Loading