Skip to content

Commit a620b79

Browse files
committed
Fixed bug #69054 (Null dereference in readline_(read|write)_history() without parameters)
1 parent 7667f8e commit a620b79

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ PHP NEWS
1818
. Fixed bug #68638 (pg_update() fails to store infinite values).
1919
(william dot welter at 4linux dot com dot br, Laruence)
2020

21+
- Readline:
22+
. Fixed bug #69054 (Null dereference in readline_(read|write)_history() without
23+
parameters). (Laruence)
24+
2125
- CGI:
2226
. Fixed bug #69015 (php-cgi's getopt does not see $argv). (Laruence)
2327

ext/readline/readline.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,13 @@ PHP_FUNCTION(readline_read_history)
400400
return;
401401
}
402402

403-
if (php_check_open_basedir(arg TSRMLS_CC)) {
403+
if (arg && php_check_open_basedir(arg TSRMLS_CC)) {
404404
RETURN_FALSE;
405405
}
406406

407407
/* XXX from & to NYI */
408408
if (read_history(arg)) {
409+
/* If filename is NULL, then read from `~/.history' */
409410
RETURN_FALSE;
410411
} else {
411412
RETURN_TRUE;
@@ -424,7 +425,7 @@ PHP_FUNCTION(readline_write_history)
424425
return;
425426
}
426427

427-
if (php_check_open_basedir(arg TSRMLS_CC)) {
428+
if (arg && php_check_open_basedir(arg TSRMLS_CC)) {
428429
RETURN_FALSE;
429430
}
430431

ext/readline/tests/bug69054.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #69054 (Null dereference in readline_(read|write)_history() without parameters)
3+
--SKIPIF--
4+
<?php if (!extension_loaded("readline") || !function_exists('readline_add_history')) die("skip"); ?>
5+
--INI--
6+
open_basedir=/tmp
7+
--FILE--
8+
<?php readline_read_history(); ?>
9+
==DONE==
10+
--EXPECT--
11+
==DONE==

0 commit comments

Comments
 (0)