Bladeren bron

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

tags/v0.9.7
Michael Brown 15 jaren geleden
bovenliggende
commit
3206e470d0
1 gewijzigde bestanden met toevoegingen van 12 en 1 verwijderingen
  1. 12
    1
      src/usr/imgmgmt.c

+ 12
- 1
src/usr/imgmgmt.c Bestand weergeven

@@ -43,7 +43,10 @@
43 43
  */
44 44
 int imgfetch ( struct image *image, const char *uri_string,
45 45
 	       int ( * image_register ) ( struct image *image ) ) {
46
+	char uri_string_redacted[ strlen ( uri_string ) + 3 /* "***" */
47
+				  + 1 /* NUL */ ];
46 48
 	struct uri *uri;
49
+	const char *password;
47 50
 	int rc;
48 51
 
49 52
 	if ( ! ( uri = parse_uri ( uri_string ) ) )
@@ -51,9 +54,17 @@ int imgfetch ( struct image *image, const char *uri_string,
51 54
 
52 55
 	image_set_uri ( image, uri );
53 56
 
57
+	/* Redact password portion of URI, if necessary */
58
+	password = uri->password;
59
+	if ( password )
60
+		uri->password = "***";
61
+	unparse_uri ( uri_string_redacted, sizeof ( uri_string_redacted ),
62
+		      uri );
63
+	uri->password = password;
64
+
54 65
 	if ( ( rc = create_downloader ( &monojob, image, image_register,
55 66
 					LOCATION_URI, uri ) ) == 0 )
56
-		rc = monojob_wait ( uri_string );
67
+		rc = monojob_wait ( uri_string_redacted );
57 68
 
58 69
 	uri_put ( uri );
59 70
 	return rc;

Laden…
Annuleren
Opslaan