david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[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
1 changed files with 12 additions and 1 deletions

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;