File: fuzzy_clone.patch

package info (click to toggle)
python-ssdeep 3.1%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 148 kB
  • ctags: 98
  • sloc: python: 424; makefile: 23
file content (56 lines) | stat: -rw-r--r-- 2,034 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From: Helmut Grohne <helmut@subdivi.de>
Subject: support copy method of haslib objects
Last-Modified: 2014-09-28

Index: python-ssdeep-3.1/ssdeep/__init__.py
===================================================================
--- python-ssdeep-3.1.orig/ssdeep/__init__.py	2014-08-07 21:31:22.000000000 +0200
+++ python-ssdeep-3.1/ssdeep/__init__.py	2014-09-28 15:29:37.000000000 +0200
@@ -44,6 +44,18 @@
         if self._state == ffi.NULL:
             raise InternalError("Unable to create state object")
 
+    def copy(self):
+        """Create a copy of this hash object.
+
+        :raises InternalError: If the lib returns an internal error
+        """
+        newstate = binding.lib.fuzzy_clone(self._state)
+        if newstate == ffi.NULL:
+            raise InternalError("cloning of fuzzy state object failed")
+        new = Hash.__new__(Hash)
+        new._state = newstate
+        return new
+
     def update(self, buf, encoding="utf-8"):
         """
          Feed the data contained in the given buffer to the state.
Index: python-ssdeep-3.1/ssdeep/binding.py
===================================================================
--- python-ssdeep-3.1.orig/ssdeep/binding.py	2014-08-07 21:31:22.000000000 +0200
+++ python-ssdeep-3.1/ssdeep/binding.py	2014-09-28 14:36:35.000000000 +0200
@@ -11,6 +11,8 @@
 
     struct fuzzy_state;
     struct fuzzy_state *fuzzy_new(void);
+    struct fuzzy_state *fuzzy_clone(
+        const struct fuzzy_state *);
     int fuzzy_update(
         struct fuzzy_state *,
         const unsigned char *,
@@ -62,6 +64,7 @@
     struct fuzzy_state {};
     const long FUZZY_FLAG_ELIMSEQ = 0;
     const long FUZZY_FLAG_NOTRUNC = 0;
+    int (*fuzzy_clone)(const struct fuzzy_state *) = NULL;
     int (*fuzzy_digest)(
         const struct fuzzy_state *,
         char *,
@@ -91,6 +94,7 @@
     "ssdeep_HAS_STATEFUL_HASHING": (
         "FUZZY_FLAG_ELIMSEQ",
         "FUZZY_FLAG_NOTRUNC",
+        "fuzzy_clone",
         "fuzzy_digest",
         "fuzzy_free",
         "fuzzy_new",