]> granicus.if.org Git - php/commitdiff
fix possible crash in posix_access()
authorNuno Lopes <nlopess@php.net>
Sat, 16 Sep 2006 17:41:57 +0000 (17:41 +0000)
committerNuno Lopes <nlopess@php.net>
Sat, 16 Sep 2006 17:41:57 +0000 (17:41 +0000)
ext/posix/posix.c
ext/posix/tests/001.phpt [new file with mode: 0644]

index 418f1f1a6bf97f278531578935b723645ed38f27..4d1d0be3712cd90fd2cbaa067b2343fcbf038855 100644 (file)
@@ -771,6 +771,10 @@ PHP_FUNCTION(posix_access)
        }
 
        path = expand_filepath(filename, NULL TSRMLS_CC);
+       if (!path) {
+               POSIX_G(last_error) = EIO;
+               RETURN_FALSE;
+       }
 
        if (php_check_open_basedir_ex(path, 0 TSRMLS_CC) ||
                        (PG(safe_mode) && (!php_checkuid_ex(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR, CHECKUID_NO_ERRORS)))) {
diff --git a/ext/posix/tests/001.phpt b/ext/posix/tests/001.phpt
new file mode 100644 (file)
index 0000000..e6c629c
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+posix_access() with bogus paths
+--SKIPIF--
+<?php if (!extension_loaded('posix')) echo 'skip'; ?>
+--FILE--
+<?php
+
+var_dump(posix_access(str_repeat('bogus path', 1042)));
+
+?>
+--EXPECT--
+bool(false)