Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2022-09-30 00:21:13 +0300
committerMichael Grunder <michael.grunder@gmail.com>2022-10-01 20:03:48 +0300
commit8746493296b5cadbfce4b57b86313936627c0216 (patch)
tree2978cd44be6b19c9a3e48b40c3f691ef38dd422e
parentdc9af5296bedef126d2fa7d5ce31181c2824ad94 (diff)
Add back a default switch case for setoption handler
We can't use `EMPTY_SWITCH_DEFAULT_CASE` here as the underlying macro will actually panic, as it calls `ZEND_UNREACHABLE` under the hood.
-rw-r--r--redis_commands.c4
-rw-r--r--tests/RedisTest.php5
2 files changed, 8 insertions, 1 deletions
diff --git a/redis_commands.c b/redis_commands.c
index 35152b7c..3db45146 100644
--- a/redis_commands.c
+++ b/redis_commands.c
@@ -5566,7 +5566,9 @@ void redis_setoption_handler(INTERNAL_FUNCTION_PARAMETERS,
RETURN_TRUE;
}
break;
- EMPTY_SWITCH_DEFAULT_CASE()
+ default:
+ php_error_docref(NULL, E_WARNING, "Unknown option '" ZEND_LONG_FMT "'", option);
+ break;
}
RETURN_FALSE;
}
diff --git a/tests/RedisTest.php b/tests/RedisTest.php
index 9c06b64e..c5a87d15 100644
--- a/tests/RedisTest.php
+++ b/tests/RedisTest.php
@@ -6985,6 +6985,11 @@ class Redis_Test extends TestSuite
$this->assertEquals('bar', $this->redis->get('key2'));
}
+ /* Make sure we handle a bad option value gracefully */
+ public function testBadOptionValue() {
+ $this->assertFalse(@$this->redis->setOption(pow(2, 32), false));
+ }
+
public function testSession_regenerateSessionId_noLock_noDestroy() {
$this->setSessionHandler();
$sessionId = $this->generateSessionId();