Make Signals compatible with nix, implement TryFrom<&str> (#1599)
* Make our signals compatible to nix Signals * no-default nix
This commit is contained in:
parent
20f1119bab
commit
25409119ff
@ -107,7 +107,7 @@ serde_json = { version = "1.0", optional = true, default-features = false, featu
|
|||||||
miniz_oxide = { version = "0.7.1", optional = true}
|
miniz_oxide = { version = "0.7.1", optional = true}
|
||||||
hostname = { version = "^0.3", optional = true } # Is there really no gethostname in the stdlib?
|
hostname = { version = "^0.3", optional = true } # Is there really no gethostname in the stdlib?
|
||||||
rand_core = { version = "0.6", optional = true }
|
rand_core = { version = "0.6", optional = true }
|
||||||
nix = { version = "0.26", optional = true , features = ["socket", "poll"] }
|
nix = { version = "0.26", default-features = false, optional = true, features = ["signal", "socket", "poll"] }
|
||||||
uuid = { version = "1.4", optional = true, features = ["serde", "v4"] }
|
uuid = { version = "1.4", optional = true, features = ["serde", "v4"] }
|
||||||
clap = {version = "4.0", features = ["derive", "wrap_help"], optional = true} # CLI parsing, for libafl_bolts::cli / the `cli` feature
|
clap = {version = "4.0", features = ["derive", "wrap_help"], optional = true} # CLI parsing, for libafl_bolts::cli / the `cli` feature
|
||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
|
@ -299,6 +299,38 @@ pub enum Signal {
|
|||||||
SigTrap = SIGTRAP,
|
SigTrap = SIGTRAP,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TryFrom<&str> for Signal {
|
||||||
|
type Error = Error;
|
||||||
|
|
||||||
|
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||||
|
Ok(match value {
|
||||||
|
"SIGABRT" => Signal::SigAbort,
|
||||||
|
"SIGBUS" => Signal::SigBus,
|
||||||
|
"SIGFPE" => Signal::SigFloatingPointException,
|
||||||
|
"SIGILL" => Signal::SigIllegalInstruction,
|
||||||
|
"SIGPIPE" => Signal::SigPipe,
|
||||||
|
"SIGSEGV" => Signal::SigSegmentationFault,
|
||||||
|
"SIGUSR2" => Signal::SigUser2,
|
||||||
|
"SIGALRM" => Signal::SigAlarm,
|
||||||
|
"SIGHUP" => Signal::SigHangUp,
|
||||||
|
"SIGKILL" => Signal::SigKill,
|
||||||
|
"SIGQUIT" => Signal::SigQuit,
|
||||||
|
"SIGTERM" => Signal::SigTerm,
|
||||||
|
"SIGINT" => Signal::SigInterrupt,
|
||||||
|
"SIGTRAP" => Signal::SigTrap,
|
||||||
|
_ => return Err(Error::illegal_argument(format!("No signal named {value}"))),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
impl From<Signal> for nix::sys::signal::Signal {
|
||||||
|
fn from(value: Signal) -> Self {
|
||||||
|
// we can be semi-certain that all signals exist in nix.
|
||||||
|
i32::from(value).try_into().unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A list of crashing signals
|
/// A list of crashing signals
|
||||||
pub static CRASH_SIGNALS: &[Signal] = &[
|
pub static CRASH_SIGNALS: &[Signal] = &[
|
||||||
Signal::SigAbort,
|
Signal::SigAbort,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user