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
76
77
78
|
From 99e8980282d7f05f8956bc071eaa823513d44c15 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 10 Sep 2021 14:35:47 +0200
Subject: [PATCH] use ZEND_ACC_NOT_SERIALIZABLE for PHP 8.1
---
pkcs11int.h | 33 +++++++++++++++++++++++++++++++++
pkcs11key.c | 6 +++++-
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/pkcs11int.h b/pkcs11int.h
index 69cd92a..dfbe62b 100644
--- a/pkcs11int.h
+++ b/pkcs11int.h
@@ -192,6 +192,8 @@ DECLARE_MAGIC_FUNCS(pkcs11_digestcontext, DigestContext)
DECLARE_MAGIC_FUNCS(pkcs11_encryptioncontext, EncryptionContext)
DECLARE_MAGIC_FUNCS(pkcs11_decryptioncontext, DecryptionContext)
+#if PHP_VERSION_ID < 80100
+
#define DEFINE_MAGIC_FUNCS(tt, lowername, classname) \
static zend_object *tt##_ctor(zend_class_entry *ce) { \
tt##_object *objval = zend_object_alloc(sizeof(tt##_object), ce); \
@@ -220,6 +222,37 @@ void register_##tt() {
ce_Pkcs11_##classname->unserialize = zend_class_unserialize_deny; \
}
+#else
+
+#define DEFINE_MAGIC_FUNCS(tt, lowername, classname) \
+static zend_object *tt##_ctor(zend_class_entry *ce) { \
+ tt##_object *objval = zend_object_alloc(sizeof(tt##_object), ce); \
+ \
+ zend_object_std_init(&objval->std, ce); \
+ object_properties_init(&objval->std, ce); \
+ objval->std.handlers = &tt##_handlers; \
+ \
+ return &objval->std; \
+} \
+static void tt##_dtor(zend_object *zobj) { \
+ tt##_object *objval = tt##_from_zend_object(zobj); \
+ tt##_shutdown(objval); \
+ zend_object_std_dtor(&objval->std); \
+} \
+void register_##tt() { \
+ zend_class_entry ce; \
+ memcpy(&tt##_handlers, &std_object_handlers, sizeof(zend_object_handlers)); \
+ INIT_NS_CLASS_ENTRY(ce, "Pkcs11", #classname, lowername##_class_functions); \
+ ce.create_object = tt##_ctor; \
+ tt##_handlers.offset = XtOffsetOf(tt##_object, std); \
+ tt##_handlers.clone_obj = NULL; \
+ tt##_handlers.free_obj = tt##_dtor; \
+ ce_Pkcs11_##classname = zend_register_internal_class(&ce); \
+ ce_Pkcs11_##classname->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE; \
+}
+
+#endif
+
extern void pkcs11_error(CK_RV rv, char *error);
extern void general_error(char *generic, char *specific);
diff --git a/pkcs11key.c b/pkcs11key.c
index 1b84b43..2d7f493 100644
--- a/pkcs11key.c
+++ b/pkcs11key.c
@@ -612,6 +612,10 @@ void register_pkcs11_key() {
pkcs11_key_handlers.offset = XtOffsetOf(pkcs11_key_object, std);
pkcs11_key_handlers.clone_obj = NULL;
ce_Pkcs11_Key = zend_register_internal_class_ex(&ce, ce_Pkcs11_P11Object);
+#if PHP_VERSION_ID < 80100
ce_Pkcs11_Key->serialize = zend_class_serialize_deny;
ce_Pkcs11_Key->unserialize = zend_class_unserialize_deny;
-}
\ No newline at end of file
+#else
+ ce_Pkcs11_Key->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
+#endif
+}
|