authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-12-30 23:14:34-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-02 13:16:17-07:00
log9dc25dd0b695c907e861bfd5a974cf454e657228
treeef5b97ab68330ec2b2b9a018b53d1e79aeef19f7
parent55243cfb31e40f09503fbc5b4bb63e7a5d3d87eb

stage2: fix UAF of system_libs


2 files changed, 7 insertions(+), 1 deletions(-)

src/Compilation.zig+1-1
...@@ -1985,7 +1985,7 @@ pub fn update(comp: *Compilation) !void {...@@ -1985,7 +1985,7 @@ pub fn update(comp: *Compilation) !void {
19851985
1986 // This resets the link.File to operate as if we called openPath() in create()1986 // This resets the link.File to operate as if we called openPath() in create()
1987 // instead of simulating -fno-emit-bin.1987 // instead of simulating -fno-emit-bin.
1988 var options = comp.bin_file.options;1988 var options = comp.bin_file.options.move();
1989 if (comp.whole_bin_sub_path) |sub_path| {1989 if (comp.whole_bin_sub_path) |sub_path| {
1990 options.emit = .{1990 options.emit = .{
1991 .directory = tmp_artifact_directory.?,1991 .directory = tmp_artifact_directory.?,
src/link.zig+6
...@@ -167,6 +167,12 @@ pub const Options = struct {...@@ -167,6 +167,12 @@ pub const Options = struct {
167 pub fn effectiveOutputMode(options: Options) std.builtin.OutputMode {167 pub fn effectiveOutputMode(options: Options) std.builtin.OutputMode {
168 return if (options.use_lld) .Obj else options.output_mode;168 return if (options.use_lld) .Obj else options.output_mode;
169 }169 }
170
171 pub fn move(self: *Options) Options {
172 const copied_state = self.*;
173 self.system_libs = .{};
174 return copied_state;
175 }
170};176};
171177
172pub const File = struct {178pub const File = struct {