|
|
af9dc8 |
Adapted for PHP 5.4.16 from
|
|
|
af9dc8 |
|
|
|
af9dc8 |
From 56754a7f9eba0e4f559b6ca081d9f2a447b3f159 Mon Sep 17 00:00:00 2001
|
|
|
af9dc8 |
From: Stanislav Malyshev <stas@php.net>
|
|
|
af9dc8 |
Date: Sun, 28 Sep 2014 14:19:31 -0700
|
|
|
af9dc8 |
Subject: [PATCH] Fixed bug #68044: Integer overflow in unserialize() (32-bits
|
|
|
af9dc8 |
only)
|
|
|
af9dc8 |
|
|
|
af9dc8 |
---
|
|
|
af9dc8 |
NEWS | 5 ++++-
|
|
|
af9dc8 |
ext/standard/tests/serialize/bug68044.phpt | 12 ++++++++++++
|
|
|
af9dc8 |
ext/standard/var_unserializer.c | 4 ++--
|
|
|
af9dc8 |
ext/standard/var_unserializer.re | 2 +-
|
|
|
af9dc8 |
4 files changed, 19 insertions(+), 4 deletions(-)
|
|
|
af9dc8 |
create mode 100644 ext/standard/tests/serialize/bug68044.phpt
|
|
|
af9dc8 |
|
|
|
af9dc8 |
diff --git a/ext/standard/tests/serialize/bug68044.phpt b/ext/standard/tests/serialize/bug68044.phpt
|
|
|
af9dc8 |
new file mode 100644
|
|
|
af9dc8 |
index 0000000..031e44e
|
|
|
af9dc8 |
--- /dev/null
|
|
|
af9dc8 |
+++ b/ext/standard/tests/serialize/bug68044.phpt
|
|
|
af9dc8 |
@@ -0,0 +1,12 @@
|
|
|
af9dc8 |
+--TEST--
|
|
|
af9dc8 |
+Bug #68044 Integer overflow in unserialize() (32-bits only)
|
|
|
af9dc8 |
+--FILE--
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+ echo unserialize('C:3:"XYZ":18446744075857035259:{}');
|
|
|
af9dc8 |
+?>
|
|
|
af9dc8 |
+===DONE==
|
|
|
af9dc8 |
+--EXPECTF--
|
|
|
af9dc8 |
+Warning: Insufficient data for unserializing - %d required, 1 present in %s/bug68044.php on line 2
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+Notice: unserialize(): Error at offset 32 of 33 bytes in %s/bug68044.php on line 2
|
|
|
af9dc8 |
+===DONE==
|
|
|
af9dc8 |
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
|
|
|
af9dc8 |
index 657051f..8129da3 100644
|
|
|
af9dc8 |
--- a/ext/standard/var_unserializer.c
|
|
|
af9dc8 |
+++ b/ext/standard/var_unserializer.c
|
|
|
af9dc8 |
@@ -344,7 +344,7 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
|
|
|
af9dc8 |
|
|
|
af9dc8 |
(*p) += 2;
|
|
|
af9dc8 |
|
|
|
af9dc8 |
- if (datalen < 0 || (*p) + datalen >= max) {
|
|
|
af9dc8 |
+ if (datalen < 0 || (max - (*p)) <= datalen) {
|
|
|
af9dc8 |
zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %ld present", datalen, (long)(max - (*p)));
|
|
|
af9dc8 |
return 0;
|
|
|
af9dc8 |
}
|
|
|
af9dc8 |
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
|
|
|
af9dc8 |
index 1307508..6de1583 100644
|
|
|
af9dc8 |
--- a/ext/standard/var_unserializer.re
|
|
|
af9dc8 |
+++ b/ext/standard/var_unserializer.re
|
|
|
af9dc8 |
@@ -350,7 +350,7 @@ static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce)
|
|
|
af9dc8 |
|
|
|
af9dc8 |
(*p) += 2;
|
|
|
af9dc8 |
|
|
|
af9dc8 |
- if (datalen < 0 || (*p) + datalen >= max) {
|
|
|
af9dc8 |
+ if (datalen < 0 || (max - (*p)) <= datalen) {
|
|
|
af9dc8 |
zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %ld present", datalen, (long)(max - (*p)));
|
|
|
af9dc8 |
return 0;
|
|
|
af9dc8 |
}
|
|
|
af9dc8 |
--
|
|
|
af9dc8 |
2.1.0
|
|
|
af9dc8 |
|