Skip to content

Commit c7891e2

Browse files
committed
Clippy
1 parent e9bd38c commit c7891e2

File tree

8 files changed

+23
-29
lines changed

8 files changed

+23
-29
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ bundled = ["z3/bundled"]
2525
opt-level = 3
2626

2727
[dependencies]
28-
elf = "0.7.4"
2928
jingle = { git = "https://github.com/toolCHAINZ/jingle", branch = "dev", features = ["gimli"] }
3029
z3 = { git = "https://github.com/prove-rs/z3.rs.git", branch = "master" }
3130
serde = { version = "1.0.203", features = ["derive"] }

src/config/constraint.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ pub fn gen_memory_constraint(
125125
+ Sync
126126
+ Clone
127127
+ 'static {
128-
return move |jingle, state, _addr| {
128+
move |jingle, state, _addr| {
129129
let data = state.read_varnode(&state.varnode(&m.space, m.address, m.size).unwrap())?;
130130
let constraint = data._eq(&BV::from_u64(jingle.z3, m.value as u64, data.get_size()));
131131
Ok(constraint)
132-
};
132+
}
133133
}
134134

135135
/// Generates a state constraint that a given varnode must be equal to a given value
@@ -142,11 +142,11 @@ pub fn gen_register_constraint(
142142
+ Send
143143
+ Sync
144144
+ Clone {
145-
return move |jingle, state, _addr| {
145+
move |jingle, state, _addr| {
146146
let data = state.read_varnode(&vn)?;
147147
let constraint = data._eq(&BV::from_u64(jingle.z3, value, data.get_size()));
148148
Ok(constraint)
149-
};
149+
}
150150
}
151151

152152
/// Generates a constraint enforcing that the given varnode contains a pointer into the default
@@ -157,7 +157,7 @@ pub fn gen_register_pointer_constraint<'ctx>(
157157
m: Option<PointerRangeConstraints>,
158158
) -> impl for<'a> Fn(&JingleContext<'a>, &State<'a>, u64) -> Result<Bool<'a>, CrackersError> + 'ctx + Clone
159159
{
160-
return move |jingle, state, _addr| {
160+
move |jingle, state, _addr| {
161161
let m = m.clone();
162162
let val = value
163163
.as_bytes()
@@ -186,7 +186,7 @@ pub fn gen_register_pointer_constraint<'ctx>(
186186
}
187187
}
188188
Ok(constraint)
189-
};
189+
}
190190
}
191191

192192
/// Generates an invariant enforcing that the given varnode, read from a given state, is within
@@ -200,7 +200,7 @@ pub fn gen_pointer_range_state_invariant<'ctx>(
200200
) -> Result<Option<Bool<'a>>, CrackersError>
201201
+ 'ctx
202202
+ Clone {
203-
return move |jingle, vn, state| {
203+
move |jingle, vn, state| {
204204
match vn {
205205
ResolvedVarnode::Direct(d) => {
206206
// todo: this is gross
@@ -228,7 +228,7 @@ pub fn gen_pointer_range_state_invariant<'ctx>(
228228
Ok(Some(Bool::or(jingle.z3, terms.as_slice())))
229229
}
230230
}
231-
};
231+
}
232232
}
233233

234234
pub fn gen_pointer_range_transition_invariant(
@@ -238,7 +238,7 @@ pub fn gen_pointer_range_transition_invariant(
238238
+ Sync
239239
+ Clone
240240
+ 'static {
241-
return move |jingle, block| {
241+
move |jingle, block| {
242242
let mut bools = vec![];
243243
if let Some(r) = &m.read {
244244
let inv = gen_pointer_range_state_invariant(r.clone());
@@ -257,5 +257,5 @@ pub fn gen_pointer_range_transition_invariant(
257257
}
258258
}
259259
Ok(Some(Bool::and(jingle.z3, &bools)))
260-
};
260+
}
261261
}

src/gadget/another_iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ where
3232
}
3333
}
3434
}
35-
impl<'ctx, 'a, T> Iterator for TraceCandidateIterator<'ctx, 'a, T>
35+
impl<'a, T> Iterator for TraceCandidateIterator<'_, 'a, T>
3636
where
3737
T: Iterator<Item = &'a Gadget>,
3838
{

src/gadget/candidates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl CandidateBuilder {
3939
}
4040
}
4141
// We never found ANY candidates for ANYTHING
42-
if candidates.len() == 0 {
42+
if candidates.is_empty() {
4343
Err(UnsimulatedOperation { index: 0 })
4444
}
4545
// We never found candidates for something

src/gadget/library/mod.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl RegisterManager for GadgetLibrary {
105105
}
106106

107107
fn get_register_name(&self, location: &VarNode) -> Option<&str> {
108-
self.varnode_to_register.get(&location).map(|c| c.as_str())
108+
self.varnode_to_register.get(location).map(|c| c.as_str())
109109
}
110110

111111
fn get_registers(&self) -> Vec<(VarNode, String)> {
@@ -118,12 +118,10 @@ mod tests {
118118
use std::fs;
119119
use std::path::Path;
120120

121-
use elf::endian::AnyEndian;
122-
use elf::ElfBytes;
123-
use jingle::sleigh::context::SleighContextBuilder;
124-
125121
use crate::gadget::library::builder::GadgetLibraryParams;
126122
use crate::gadget::library::GadgetLibrary;
123+
use jingle::sleigh::context::SleighContextBuilder;
124+
use object::File;
127125

128126
#[test]
129127
fn test_load_library() {
@@ -132,12 +130,9 @@ mod tests {
132130
.unwrap();
133131
let path = Path::new("../bin/vuln");
134132
let data = fs::read(path).unwrap();
135-
let elf = ElfBytes::<AnyEndian>::minimal_parse(data.as_slice()).unwrap();
136-
137-
let bin_sleigh = builder
138-
.set_image(Image::try_from(elf).unwrap())
139-
.build("x86:LE:64:default")
140-
.unwrap();
133+
let file = File::parse(&*data).unwrap();
134+
let sleigh = builder.build("x86:LE:64:default").unwrap();
135+
let bin_sleigh = sleigh.initialize_with_image(file).unwrap();
141136
let _lib =
142137
GadgetLibrary::build_from_image(bin_sleigh, &GadgetLibraryParams::default()).unwrap();
143138
}

src/gadget/signature.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl GadgetSignature {
6565
}
6666
}
6767

68-
impl<'ctx> From<&ModeledBlock<'ctx>> for GadgetSignature {
68+
impl From<&ModeledBlock<'_>> for GadgetSignature {
6969
fn from(value: &ModeledBlock) -> Self {
7070
let mut outputs = Vec::new();
7171
let mut inputs = Vec::new();

src/synthesis/selection_strategy/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub trait InstrLen {
1616
fn instr_len(&self) -> usize;
1717
}
1818

19-
impl<'ctx> InstrLen for ModeledBlock<'ctx> {
19+
impl InstrLen for ModeledBlock<'_> {
2020
fn instr_len(&self) -> usize {
2121
self.instructions.len()
2222
}
@@ -33,7 +33,7 @@ impl<T: InstrLen> InstrLen for &T {
3333
(*self).instr_len()
3434
}
3535
}
36-
impl<'ctx> InstrLen for ModeledInstruction<'ctx> {
36+
impl InstrLen for ModeledInstruction<'_> {
3737
fn instr_len(&self) -> usize {
3838
1
3939
}
@@ -70,7 +70,7 @@ pub enum OuterProblem<'ctx> {
7070
OptimizeProb(OptimizationProblem<'ctx>),
7171
}
7272

73-
impl<'ctx> OuterProblem<'ctx> {
73+
impl OuterProblem<'_> {
7474
pub(crate) fn get_assignments(&mut self) -> Result<AssignmentResult, CrackersError> {
7575
match self {
7676
OuterProblem::SatProb(s) => s.get_assignments(),

src/synthesis/slot_assignments/display.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub(crate) struct SlotAssignmentConflictDisplay<'a> {
1010
pub(crate) conflict: &'a ConflictClause,
1111
}
1212

13-
impl<'a> Display for SlotAssignmentConflictDisplay<'a> {
13+
impl Display for SlotAssignmentConflictDisplay<'_> {
1414
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1515
match self.conflict.precondition {
1616
true => write!(f, "!")?,

0 commit comments

Comments
 (0)