diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/artifactory.c | 15 | ||||
-rw-r--r-- | src/utils.c | 6 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/artifactory.c b/src/artifactory.c index 4772602..5678d64 100644 --- a/src/artifactory.c +++ b/src/artifactory.c @@ -229,16 +229,15 @@ int jfrog_cli(struct JFRT_Auth *auth, char *args) { } const char *redactable[] = { - "--access-token=", - "--ssh-key-path=", - "--ssh-passphrase=", - "--client-cert-key-path=", - "--client-cert-path=", - "--password=", - NULL, + auth->access_token, + auth->ssh_key_path, + auth->ssh_passphrase, + auth->client_cert_key_path, + auth->client_cert_path, + auth->password, }; snprintf(cmd, sizeof(cmd) - 1, "jf %s %s", args, auth_args); - redact_sensitive(redactable, cmd, cmd_redacted, sizeof(cmd_redacted) - 1); + redact_sensitive(redactable, sizeof(redactable) / sizeof (*redactable), cmd, cmd_redacted, sizeof(cmd_redacted) - 1); guard_free(auth_args); guard_strlist_free(&arg_map); diff --git a/src/utils.c b/src/utils.c index 7b77020..86622ad 100644 --- a/src/utils.c +++ b/src/utils.c @@ -707,7 +707,7 @@ char *collapse_whitespace(char **s) { * @param maxlen maximum length of dest string * @return 0 on success, -1 on error */ -int redact_sensitive(const char **to_redact, char *src, char *dest, size_t maxlen) { +int redact_sensitive(const char **to_redact, size_t to_redact_size, char *src, char *dest, size_t maxlen) { const char *redacted = "***REDACTED***"; char *tmp = calloc(strlen(redacted) + strlen(src) + 1, sizeof(*tmp)); @@ -716,8 +716,8 @@ int redact_sensitive(const char **to_redact, char *src, char *dest, size_t maxle } strcpy(tmp, src); - for (size_t i = 0; to_redact[i] != NULL; i++) { - if (strstr(tmp, to_redact[i])) { + for (size_t i = 0; i < to_redact_size; i++) { + if (to_redact[i] && strstr(tmp, to_redact[i])) { replace_text(tmp, to_redact[i], redacted, 0); break; } |