Skip to content

Commit 6a62544

Browse files
committed
Prevent a crash if stars align
1 parent 2785824 commit 6a62544

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ where
202202
)
203203
.as_bytes(),
204204
);
205+
// We need the payload to be NUL-terminated. mmap(2) will guarantee that the returned region
206+
// will be filled with zeroes, but if the trampoline + payload size happens to be page-aligned,
207+
// we will segfault unless this extra explicit NUL is added!
208+
shellcode.extend(b"\x00");
205209

206210
Ok(shellcode)
207211
}

0 commit comments

Comments
 (0)