Skip to content

Commit 0d6f41b

Browse files
steveklabnikpietroalbini
authored andcommitted
Remove rustdoc plugins
See CVE-2018-1000622.
1 parent 2e6a655 commit 0d6f41b

File tree

2 files changed

+12
-58
lines changed

2 files changed

+12
-58
lines changed

src/librustdoc/lib.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub fn opts() -> Vec<RustcOptGroup> {
159159
o.optmulti("", "extern", "pass an --extern to rustc", "NAME=PATH")
160160
}),
161161
stable("plugin-path", |o| {
162-
o.optmulti("", "plugin-path", "directory to load plugins from", "DIR")
162+
o.optmulti("", "plugin-path", "removed", "DIR")
163163
}),
164164
stable("C", |o| {
165165
o.optmulti("C", "codegen", "pass a codegen option to rustc", "OPT[=VALUE]")
@@ -172,7 +172,7 @@ pub fn opts() -> Vec<RustcOptGroup> {
172172
"PASSES")
173173
}),
174174
stable("plugins", |o| {
175-
o.optmulti("", "plugins", "space separated list of plugins to also load",
175+
o.optmulti("", "plugins", "removed",
176176
"PLUGINS")
177177
}),
178178
stable("no-default", |o| {
@@ -710,9 +710,16 @@ where R: 'static + Send,
710710
}
711711
}
712712

713+
if !plugins.is_empty() {
714+
eprintln!("WARNING: --plugins no longer functions; see CVE-2018-1000622");
715+
}
716+
717+
if !plugin_path.is_none() {
718+
eprintln!("WARNING: --plugin-path no longer functions; see CVE-2018-1000622");
719+
}
720+
713721
// Load all plugins/passes into a PluginManager
714-
let path = plugin_path.unwrap_or("/tmp/rustdoc/plugins".to_string());
715-
let mut pm = plugins::PluginManager::new(PathBuf::from(path));
722+
let mut pm = plugins::PluginManager::new();
716723
for pass in &passes {
717724
let plugin = match passes::PASSES.iter()
718725
.position(|&(p, ..)| {
@@ -726,10 +733,6 @@ where R: 'static + Send,
726733
};
727734
pm.add_plugin(plugin);
728735
}
729-
info!("loading plugins...");
730-
for pname in plugins {
731-
pm.load_plugin(pname);
732-
}
733736

734737
// Run everything!
735738
info!("Executing passes/plugins");
@@ -745,8 +748,6 @@ fn check_deprecated_options(matches: &getopts::Matches, diag: &errors::Handler)
745748
let deprecated_flags = [
746749
"input-format",
747750
"output-format",
748-
"plugin-path",
749-
"plugins",
750751
"no-defaults",
751752
"passes",
752753
];

src/librustdoc/plugins.rs

+1-48
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,20 @@
1212

1313
use clean;
1414

15-
use std::mem;
16-
use std::string::String;
17-
use std::path::PathBuf;
18-
19-
use rustc_metadata::dynamic_lib as dl;
20-
2115
pub type PluginResult = clean::Crate;
2216
pub type PluginCallback = fn (clean::Crate) -> PluginResult;
2317

2418
/// Manages loading and running of plugins
2519
pub struct PluginManager {
26-
dylibs: Vec<dl::DynamicLibrary> ,
2720
callbacks: Vec<PluginCallback> ,
28-
/// The directory plugins will be loaded from
29-
pub prefix: PathBuf,
3021
}
3122

3223
impl PluginManager {
3324
/// Create a new plugin manager
34-
pub fn new(prefix: PathBuf) -> PluginManager {
25+
pub fn new() -> PluginManager {
3526
PluginManager {
36-
dylibs: Vec::new(),
3727
callbacks: Vec::new(),
38-
prefix,
39-
}
40-
}
41-
42-
/// Load a plugin with the given name.
43-
///
44-
/// Turns `name` into the proper dynamic library filename for the given
45-
/// platform. On windows, it turns into name.dll, on macOS, name.dylib, and
46-
/// elsewhere, libname.so.
47-
pub fn load_plugin(&mut self, name: String) {
48-
let x = self.prefix.join(libname(name));
49-
let lib_result = dl::DynamicLibrary::open(Some(&x));
50-
let lib = lib_result.unwrap();
51-
unsafe {
52-
let plugin = lib.symbol("rustdoc_plugin_entrypoint").unwrap();
53-
self.callbacks.push(mem::transmute::<*mut u8,PluginCallback>(plugin));
5428
}
55-
self.dylibs.push(lib);
5629
}
5730

5831
/// Load a normal Rust function as a plugin.
@@ -70,23 +43,3 @@ impl PluginManager {
7043
krate
7144
}
7245
}
73-
74-
#[cfg(target_os = "windows")]
75-
fn libname(mut n: String) -> String {
76-
n.push_str(".dll");
77-
n
78-
}
79-
80-
#[cfg(target_os="macos")]
81-
fn libname(mut n: String) -> String {
82-
n.push_str(".dylib");
83-
n
84-
}
85-
86-
#[cfg(all(not(target_os="windows"), not(target_os="macos")))]
87-
fn libname(n: String) -> String {
88-
let mut i = String::from("lib");
89-
i.push_str(&n);
90-
i.push_str(".so");
91-
i
92-
}

0 commit comments

Comments
 (0)