summaryrefslogtreecommitdiffstats
path: root/ssdeep-php7.patch
diff options
context:
space:
mode:
Diffstat (limited to 'ssdeep-php7.patch')
-rw-r--r--ssdeep-php7.patch100
1 files changed, 100 insertions, 0 deletions
diff --git a/ssdeep-php7.patch b/ssdeep-php7.patch
new file mode 100644
index 0000000..05dbd4e
--- /dev/null
+++ b/ssdeep-php7.patch
@@ -0,0 +1,100 @@
+From c62cadc78de1ee69ca3643441477b779d0a817e4 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@php.net>
+Date: Mon, 6 Apr 2015 10:30:12 +0200
+Subject: [PATCH] PHP 7 compatibility
+
+---
+ php_ssdeep.h | 9 +++++++++
+ ssdeep.c | 22 +++++++++++++---------
+ 2 files changed, 22 insertions(+), 9 deletions(-)
+
+diff --git a/php_ssdeep.h b/php_ssdeep.h
+index 5deaa40..9a88de0 100644
+--- a/php_ssdeep.h
++++ b/php_ssdeep.h
+@@ -47,4 +47,13 @@
+
+ extern zend_module_entry php_ssdeep_module_entry;
+ # define phpext_php_ssdeep_ptr &php_ssdeep_module_entry
++
++#if PHP_MAJOR_VERSION < 7
++typedef int strsize_t;
++#define _RETURN_STRING(s) RETURN_STRING(s, 0);
++#else
++typedef size_t strsize_t;
++#define _RETURN_STRING(s) { RETVAL_STRING(s); efree(s); return; }
++#endif
++
+ #endif
+diff --git a/ssdeep.c b/ssdeep.c
+index 3cae212..81f4e07 100644
+--- a/ssdeep.c
++++ b/ssdeep.c
+@@ -67,8 +67,12 @@ ZEND_END_ARG_INFO()
+ const zend_function_entry ssdeep_functions[] = {
+ PHP_FE(ssdeep_fuzzy_hash, arginfo_ssdeep_fuzzy_hash)
+ PHP_FE(ssdeep_fuzzy_hash_filename, arginfo_ssdeep_fuzzy_hash_filename)
+- PHP_FE(ssdeep_fuzzy_compare, arginfo_ssdeep_fuzzy_compare) {
+- NULL, NULL, NULL} /* Must be the last line in ssdeep_functions[] */
++ PHP_FE(ssdeep_fuzzy_compare, arginfo_ssdeep_fuzzy_compare)
++#ifdef PHP_FE_END
++ PHP_FE_END
++#else
++ { NULL, NULL, NULL } /* Must be the last line in ssdeep_functions[] */
++#endif
+ };
+ /* }}} */
+
+@@ -101,16 +105,16 @@ PHP_MINFO_FUNCTION(ssdeep) {
+ PHP_FUNCTION(ssdeep_fuzzy_hash) {
+ char *hash = (char *) emalloc(FUZZY_MAX_RESULT);
+ char *to_hash;
+- int to_hash_len;
++ strsize_t to_hash_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &to_hash, &to_hash_len) == FAILURE) {
+ RETURN_NULL();
+ }
+
+- if (0 != fuzzy_hash_buf((unsigned char *) to_hash, to_hash_len, hash)) {
++ if (0 != fuzzy_hash_buf((unsigned char *) to_hash, (uint32_t)to_hash_len, hash)) {
+ RETURN_FALSE;
+ } else {
+- RETURN_STRING(hash, 0);
++ _RETURN_STRING(hash);
+ }
+ }
+ /* }}} */
+@@ -120,7 +124,7 @@ PHP_FUNCTION(ssdeep_fuzzy_hash) {
+ PHP_FUNCTION(ssdeep_fuzzy_hash_filename) {
+ char *hash = (char *) emalloc(FUZZY_MAX_RESULT);
+ char *file_name;
+- int file_name_len;
++ strsize_t file_name_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file_name, &file_name_len) == FAILURE) {
+ RETURN_NULL();
+@@ -129,7 +133,7 @@ PHP_FUNCTION(ssdeep_fuzzy_hash_filename) {
+ if (0 != fuzzy_hash_filename(file_name, hash)) {
+ RETURN_FALSE;
+ } else {
+- RETURN_STRING(hash, 0);
++ _RETURN_STRING(hash);
+ }
+ }
+ /* }}} */
+@@ -138,9 +142,9 @@ PHP_FUNCTION(ssdeep_fuzzy_hash_filename) {
+ */
+ PHP_FUNCTION(ssdeep_fuzzy_compare) {
+ char *signature1 = NULL;
+- int signature1_len;
++ strsize_t signature1_len;
+ char *signature2 = NULL;
+- int signature2_len;
++ strsize_t signature2_len;
+ int match;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &signature1, &signature1_len, &signature2, &signature2_len) == FAILURE) {
+--
+2.1.0
+