]> granicus.if.org Git - php/commitdiff
Fixed bug #69054 (Null dereference in readline_(read|write)_history() without parameters)
authorXinchen Hui <laruence@php.net>
Sun, 15 Feb 2015 14:54:05 +0000 (22:54 +0800)
committerXinchen Hui <laruence@php.net>
Sun, 15 Feb 2015 14:54:05 +0000 (22:54 +0800)
NEWS
ext/readline/readline.c
ext/readline/tests/bug69054.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index a0ffd3e08c5466d45a456070b1c48bdbe302014b..3cb896089de9535ca01d78206238b3d32f7638a4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ PHP                                                                        NEWS
   . Fixed bug #68638 (pg_update() fails to store infinite values).
     (william dot welter at 4linux dot com dot br, Laruence)
 
+- Readline:
+  . Fixed bug #69054 (Null dereference in readline_(read|write)_history() without
+    parameters). (Laruence)
+
 - CGI:
   . Fixed bug #69015 (php-cgi's getopt does not see $argv). (Laruence)
 
index f48194a439162250919760acea9a9394a3c25210..8cf7734b62090c7c71daf5fe14d4df11e5fb07fc 100644 (file)
@@ -400,12 +400,13 @@ PHP_FUNCTION(readline_read_history)
                return;
        }
 
-       if (php_check_open_basedir(arg TSRMLS_CC)) {
+       if (arg && php_check_open_basedir(arg TSRMLS_CC)) {
                RETURN_FALSE;
        }
 
        /* XXX from & to NYI */
        if (read_history(arg)) {
+               /* If filename is NULL, then read from `~/.history' */
                RETURN_FALSE;
        } else {
                RETURN_TRUE;
@@ -424,7 +425,7 @@ PHP_FUNCTION(readline_write_history)
                return;
        }
 
-       if (php_check_open_basedir(arg TSRMLS_CC)) {
+       if (arg && php_check_open_basedir(arg TSRMLS_CC)) {
                RETURN_FALSE;
        }
 
diff --git a/ext/readline/tests/bug69054.phpt b/ext/readline/tests/bug69054.phpt
new file mode 100644 (file)
index 0000000..f17f803
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #69054 (Null dereference in readline_(read|write)_history() without parameters)
+--SKIPIF--
+<?php if (!extension_loaded("readline") || !function_exists('readline_add_history')) die("skip"); ?>
+--INI--
+open_basedir=/tmp
+--FILE--
+<?php readline_read_history(); ?>
+==DONE==
+--EXPECT--
+==DONE==