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
|
From 61c02e2985494b3de6ebbbd25f622085ca4b1103 Mon Sep 17 00:00:00 2001
From: Pavlo Yatsukhnenko <yatsukhnenko@gmail.com>
Date: Thu, 15 Dec 2016 15:08:17 +0200
Subject: [PATCH] Fix segfault in testSerializerIGBinary
---
library.c | 14 ++++++++------
redis.c | 6 +++---
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/library.c b/library.c
index a48fc41..4182d24 100644
--- a/library.c
+++ b/library.c
@@ -2087,14 +2087,16 @@ redis_unserialize(RedisSock* redis_sock, const char *val, int val_len,
{
/* This is most definitely not an igbinary string, so do
not try to unserialize this as one. */
- return 0;
+ break;
}
- if(igbinary_unserialize((const uint8_t *)val, (size_t)val_len,
- z_ret TSRMLS_CC) == 0
- ) {
- ret = 1;
- }
+#if (PHP_MAJOR_VERSION < 7)
+ INIT_PZVAL(z_ret);
+ ret = !igbinary_unserialize((const uint8_t *)val, (size_t)val_len, &z_ret TSRMLS_CC);
+#else
+ ret = !igbinary_unserialize((const uint8_t *)val, (size_t)val_len, z_ret TSRMLS_CC);
+#endif
+
#endif
break;
}
diff --git a/redis.c b/redis.c
index 2b27b5f..25297d6 100644
--- a/redis.c
+++ b/redis.c
@@ -527,6 +527,9 @@ static void add_class_constants(zend_class_entry *ce, int is_cluster TSRMLS_DC)
/* serializer */
zend_declare_class_constant_long(ce, ZEND_STRL("SERIALIZER_NONE"), REDIS_SERIALIZER_NONE TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("SERIALIZER_PHP"), REDIS_SERIALIZER_PHP TSRMLS_CC);
+#ifdef HAVE_REDIS_IGBINARY
+ zend_declare_class_constant_long(ce, ZEND_STRL("SERIALIZER_IGBINARY"), REDIS_SERIALIZER_IGBINARY TSRMLS_CC);
+#endif
/* scan options*/
zend_declare_class_constant_long(ce, ZEND_STRL("OPT_SCAN"), REDIS_OPT_SCAN TSRMLS_CC);
@@ -541,9 +544,6 @@ static void add_class_constants(zend_class_entry *ce, int is_cluster TSRMLS_DC)
zend_declare_class_constant_long(ce, ZEND_STRL("FAILOVER_DISTRIBUTE"), REDIS_FAILOVER_DISTRIBUTE TSRMLS_CC);
zend_declare_class_constant_long(ce, ZEND_STRL("FAILOVER_DISTRIBUTE_SLAVES"), REDIS_FAILOVER_DISTRIBUTE_SLAVES TSRMLS_CC);
}
-#ifdef HAVE_REDIS_IGBINARY
- zend_declare_class_constant_long(ce, ZEND_STRL("SERIALIZER_IGBINARY"), REDIS_SERIALIZER_IGBINARY TSRMLS_CC);
-#endif
zend_declare_class_constant_stringl(ce, "AFTER", 5, "after", 5 TSRMLS_CC);
zend_declare_class_constant_stringl(ce, "BEFORE", 6, "before", 6 TSRMLS_CC);
|