Find the api functions that contains an fuzzable integeral parameter.
(static_constraint: &APIConstraints)
| 206 | |
| 207 | /// Find the api functions that contains an fuzzable integeral parameter. |
| 208 | fn find_exploitable_func(static_constraint: &APIConstraints) -> Result<Vec<(String, Vec<usize>)>> { |
| 209 | let mut funcs = Vec::new(); |
| 210 | for gadget in get_func_gadgets() { |
| 211 | let api_name = gadget.get_func_name(); |
| 212 | let mut int_pos = gadget.get_integer_params_pos(); |
| 213 | // remove the param that constrainted by ArrayLen and ArrayIndex and FileDesc |
| 214 | if let Some(constraints) = static_constraint.get(api_name) { |
| 215 | for constraint in constraints { |
| 216 | if let Some((_, arg_pos)) = constraint.get_arg_tuple() { |
| 217 | int_pos.retain(|x| x != arg_pos); |
| 218 | } |
| 219 | if let Constraint::FileDesc(arg_pos) = constraint { |
| 220 | int_pos.retain(|x| x != arg_pos); |
| 221 | } |
| 222 | } |
| 223 | } |
| 224 | if int_pos.is_empty() { |
| 225 | continue; |
| 226 | } |
| 227 | funcs.push((api_name.to_string(), int_pos)); |
| 228 | } |
| 229 | Ok(funcs) |
| 230 | } |
| 231 | |
| 232 | /// Ranked API coverage for API in each programs. |
| 233 | type APICovRank = HashMap<String, Vec<(f32, usize)>>; |
no test coverage detected