@@ -5,7 +5,7 @@ use std::collections::HashMap;
5
5
use std:: io:: Read ;
6
6
use std:: sync:: Arc ;
7
7
8
- use bincode:: { DefaultOptions , Error as BincodeError , Options } ;
8
+ use bincode:: { DefaultOptions , Options } ;
9
9
10
10
/// Each BPF instruction is 8 bytes long and 4 byte aligned.
11
11
/// This alignment needs to be satisfied in order for a BPF code to be accepted
@@ -21,6 +21,9 @@ pub type BpfProgramRef<'a> = &'a [BpfInstruction];
21
21
/// Type that associates a thread category to a BPF program.
22
22
pub type BpfThreadMap = HashMap < String , Arc < BpfProgram > > ;
23
23
24
+ /// Binary filter deserialization errors.
25
+ pub type DeserializationError = bincode:: Error ;
26
+
24
27
/// Retrieve empty seccomp filters.
25
28
pub fn get_empty_filters ( ) -> BpfThreadMap {
26
29
let mut map = BpfThreadMap :: new ( ) ;
@@ -30,13 +33,6 @@ pub fn get_empty_filters() -> BpfThreadMap {
30
33
map
31
34
}
32
35
33
- /// Binary filter deserialization errors.
34
- #[ derive( Debug , thiserror:: Error , displaydoc:: Display ) ]
35
- pub enum DeserializationError {
36
- /// Bincode deserialization failed: {0}
37
- Bincode ( BincodeError ) ,
38
- }
39
-
40
36
/// Deserialize binary with bpf filters
41
37
pub fn deserialize_binary < R : Read > (
42
38
reader : R ,
@@ -50,8 +46,7 @@ pub fn deserialize_binary<R: Read>(
50
46
. deserialize_from :: < R , HashMap < String , BpfProgram > > ( reader) ,
51
47
// No limit is the default.
52
48
None => bincode:: deserialize_from :: < R , HashMap < String , BpfProgram > > ( reader) ,
53
- }
54
- . map_err ( DeserializationError :: Bincode ) ?;
49
+ } ?;
55
50
56
51
Ok ( result
57
52
. into_iter ( )
@@ -169,7 +164,7 @@ mod tests {
169
164
// Binary limit too low.
170
165
assert ! ( matches!(
171
166
deserialize_binary( & bytes[ ..] , Some ( 20 ) ) . unwrap_err( ) ,
172
- DeserializationError :: Bincode ( error)
167
+ error
173
168
if error. to_string( ) == "the size limit has been reached"
174
169
) ) ;
175
170
0 commit comments