Skip to content

Commit b3004fb

Browse files
author
Ilia Alshanetsky
committed
Fixed a possible memory corruption in dbase_open() with invalid open mode
1 parent e65bdff commit b3004fb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ext/dbase/dbase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ PHP_FUNCTION(dbase_open)
137137
if (Z_LVAL_PP(options) == 1) {
138138
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot open %s in write-only mode", Z_STRVAL_PP(dbf_name));
139139
RETURN_FALSE;
140-
} else if (Z_LVAL_PP(options) < 0) {
140+
} else if (Z_LVAL_PP(options) < 0 || Z_LVAL_PP(options) > 3) {
141141
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid access mode %ld", Z_LVAL_PP(options));
142142
RETURN_FALSE;
143143
}

ext/dbase/tests/002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ echo "Done\n";
3838
Warning: dbase_open(): Invalid access mode -1 in %s on line %d
3939
bool(false)
4040

41-
Warning: dbase_open(): unable to open database %s in %s on line %d
41+
Warning: dbase_open(): Invalid access mode 1000 in %s on line %d
4242
bool(false)
4343

4444
Warning: dbase_open(): unable to open database %s in %s on line %d

0 commit comments

Comments
 (0)