2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-11-26 19:29:04 +00:00

[image] Redact password from URIs displayed by imgfetch()

This commit is contained in:
Michael Brown 2009-02-17 12:10:35 +00:00
parent 6de4db5da0
commit 3206e470d0

View File

@ -43,7 +43,10 @@
*/
int imgfetch ( struct image *image, const char *uri_string,
int ( * image_register ) ( struct image *image ) ) {
char uri_string_redacted[ strlen ( uri_string ) + 3 /* "***" */
+ 1 /* NUL */ ];
struct uri *uri;
const char *password;
int rc;
if ( ! ( uri = parse_uri ( uri_string ) ) )
@ -51,9 +54,17 @@ int imgfetch ( struct image *image, const char *uri_string,
image_set_uri ( image, uri );
/* Redact password portion of URI, if necessary */
password = uri->password;
if ( password )
uri->password = "***";
unparse_uri ( uri_string_redacted, sizeof ( uri_string_redacted ),
uri );
uri->password = password;
if ( ( rc = create_downloader ( &monojob, image, image_register,
LOCATION_URI, uri ) ) == 0 )
rc = monojob_wait ( uri_string );
rc = monojob_wait ( uri_string_redacted );
uri_put ( uri );
return rc;