Skip to content

Consider mark read_string as unsafe #62

@charlesxsh

Description

@charlesxsh

Hi there,

At line 77, read_string takes an address and used without validating/checking. If passing a invalid address, it might cause serious memory issues.From the library user point of view, it should not be causing any memory issue if only safe apis are used.

lurk/src/arch/mod.rs

Lines 70 to 79 in 719734e

pub fn read_string(pid: Pid, address: c_ulonglong) -> String {
let mut string = String::new();
// Move 8 bytes up each time for next read.
let mut count = 0;
let word_size = 8;
'done: loop {
let address = unsafe { (address as *mut c_void).offset(count) };
let res: c_long = match ptrace::read(pid, address) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions