summaryrefslogtreecommitdiffstats
path: root/security/gcr/files/patch-egg_egg-secure-memory.h
blob: 56a1607b9be396f40bf4aed2660390156a70fe98 (plain) (blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
--- egg/egg-secure-memory.h.orig    Wed Sep 19 11:01:27 2012
+++ egg/egg-secure-memory.h Sat Oct 27 14:41:49 2012
@@ -27,16 +27,16 @@
 #include <stdlib.h>
 
 /* -------------------------------------------------------------------
- * Low Level Secure Memory 
- * 
- * IMPORTANT: This is pure vanila standard C, no glib. We need this 
- * because certain consumers of this protocol need to be built 
+ * Low Level Secure Memory
+ *
+ * IMPORTANT: This is pure vanila standard C, no glib. We need this
+ * because certain consumers of this protocol need to be built
  * without linking in any special libraries. ie: the PKCS#11 module.
- * 
+ *
  * Thread locking
- * 
+ *
  * In order to use these functions in a module the following functions
- * must be defined somewhere, and provide appropriate locking for 
+ * must be defined somewhere, and provide appropriate locking for
  * secure memory between threads:
  */
 
@@ -66,12 +66,12 @@ typedef struct {
 
 extern egg_secure_glob EGG_SECURE_GLOBALS;
 
-/* 
+/*
  * Main functionality
- *  
+ *
  * Allocations return NULL on failure.
- */ 
- 
+ */
+
 #define EGG_SECURE_USE_FALLBACK     0x0001
 
 #define EGG_SECURE_DECLARE(tag) \
@@ -83,23 +83,28 @@ extern egg_secure_glob EGG_SECURE_GLOBALS;
    } \
    static inline void* egg_secure_strdup (const char *str) { \
        return egg_secure_strdup_full (G_STRINGIFY (tag), str, EGG_SECURE_USE_FALLBACK); \
+   } \
+   static inline void* egg_secure_strndup (const char *str, size_t length) { \
+       return egg_secure_strndup_full (G_STRINGIFY (tag), str, length, EGG_SECURE_USE_FALLBACK); \
    }
 
 void*  egg_secure_alloc_full   (const char *tag, size_t length, int options);
 
 void*  egg_secure_realloc_full (const char *tag, void *p, size_t length, int options);
 
-void   egg_secure_free         (void* p); 
+void   egg_secure_free         (void* p);
 
-void   egg_secure_free_full    (void* p, int fallback); 
+void   egg_secure_free_full    (void* p, int fallback);
 
 void   egg_secure_clear        (void *p, size_t length);
 
-int    egg_secure_check        (const void* p); 
+int    egg_secure_check        (const void* p);
 
 void   egg_secure_validate     (void);
 
 char*  egg_secure_strdup_full  (const char *tag, const char *str, int options);
+
+char*  egg_secure_strndup_full (const char *tag, const char *str, size_t length, int options);
 
 void   egg_secure_strclear     (char *str);