Skip to content

Commit 0df68d8

Browse files
committed
Remove rustdoc plugins
See CVE-2018-1000622.
1 parent 94eb176 commit 0df68d8

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
@@ -164,7 +164,7 @@ pub fn opts() -> Vec<RustcOptGroup> {
164164
o.optmulti("", "extern", "pass an --extern to rustc", "NAME=PATH")
165165
}),
166166
stable("plugin-path", |o| {
167-
o.optmulti("", "plugin-path", "directory to load plugins from", "DIR")
167+
o.optmulti("", "plugin-path", "removed", "DIR")
168168
}),
169169
stable("C", |o| {
170170
o.optmulti("C", "codegen", "pass a codegen option to rustc", "OPT[=VALUE]")
@@ -177,7 +177,7 @@ pub fn opts() -> Vec<RustcOptGroup> {
177177
"PASSES")
178178
}),
179179
stable("plugins", |o| {
180-
o.optmulti("", "plugins", "space separated list of plugins to also load",
180+
o.optmulti("", "plugins", "removed",
181181
"PLUGINS")
182182
}),
183183
stable("no-default", |o| {
@@ -715,9 +715,16 @@ where R: 'static + Send,
715715
}
716716
}
717717

718+
if !plugins.is_empty() {
719+
eprintln!("WARNING: --plugins no longer functions; see CVE-2018-1000622");
720+
}
721+
722+
if !plugin_path.is_none() {
723+
eprintln!("WARNING: --plugin-path no longer functions; see CVE-2018-1000622");
724+
}
725+
718726
// Load all plugins/passes into a PluginManager
719-
let path = plugin_path.unwrap_or("/tmp/rustdoc/plugins".to_string());
720-
let mut pm = plugins::PluginManager::new(PathBuf::from(path));
727+
let mut pm = plugins::PluginManager::new();
721728
for pass in &passes {
722729
let plugin = match passes::PASSES.iter()
723730
.position(|&(p, ..)| {
@@ -731,10 +738,6 @@ where R: 'static + Send,
731738
};
732739
pm.add_plugin(plugin);
733740
}
734-
info!("loading plugins...");
735-
for pname in plugins {
736-
pm.load_plugin(pname);
737-
}
738741

739742
// Run everything!
740743
info!("Executing passes/plugins");
@@ -750,8 +753,6 @@ fn check_deprecated_options(matches: &getopts::Matches, diag: &errors::Handler)
750753
let deprecated_flags = [
751754
"input-format",
752755
"output-format",
753-
"plugin-path",
754-
"plugins",
755756
"no-defaults",
756757
"passes",
757758
];

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)