Skip to content

Commit

Permalink
add one more keyword that needs to be masked (#101)
Browse files Browse the repository at this point in the history
* add one more keyword that needs to be masked

* improve hide_password()
  • Loading branch information
yanw-bq authored Jul 7, 2021
1 parent efae516 commit 60975b7
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/odfesqlodbc/drvconn.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,25 @@ extern HINSTANCE s_hModule; /* Saved module handle. */

char *hide_password(const char *str) {
char *outstr, *pwdp;
const char *pwd_key = "PWD=";
const char *aad_secret_key = "AADClientSecret=";

if (!str)
return NULL;
outstr = strdup(str);
if (!outstr)
return NULL;
if (pwdp = stristr(outstr, pwd_key), pwdp) {
char *p;

for (p = pwdp + strlen(pwd_key); *p && *p != ';'; p++)
*p = 'x';
}
const char *str_to_hide[] = {"PWD=", "SecretAccessKey=", "AADClientSecret="};
size_t size = sizeof(str_to_hide)/sizeof(str_to_hide[0]);

if (pwdp = stristr(outstr, aad_secret_key), pwdp) {
char *p;
for (size_t i = 0; i < size; ++i) {
if (pwdp = stristr(outstr, str_to_hide[i]), pwdp) {
char *p;

for (p = pwdp + strlen(aad_secret_key); *p && *p != ';'; p++)
*p = 'x';
for (p = pwdp + strlen(str_to_hide[i]); *p && *p != ';'; p++)
*p = 'x';
}
}

return outstr;
}

Expand Down

0 comments on commit 60975b7

Please sign in to comment.