]> granicus.if.org Git - php/commitdiff
fix #55072 in-built web server needs to check -t option is a directory
authorDavid Soria Parra <dsp@php.net>
Wed, 29 Jun 2011 23:29:01 +0000 (23:29 +0000)
committerDavid Soria Parra <dsp@php.net>
Wed, 29 Jun 2011 23:29:01 +0000 (23:29 +0000)
sapi/cli/php_cli_server.c

index f8c68148f85ecb7acb933dd69b4e4f6189eb6dbb..b0423a1a4f7708a54a5b977a95c592e07d932a53 100644 (file)
 # define SOCK_EADDRINUSE WSAEADDRINUSE
 #endif
 
+#ifndef S_ISDIR
+#define S_ISDIR(mode)  (((mode)&S_IFMT) == S_IFDIR)
+#endif
+
 #include "ext/standard/file.h" /* for php_set_sock_blocking() :-( */
 #include "ext/standard/php_smart_str.h"
 #include "ext/standard/html.h"
@@ -2060,6 +2064,10 @@ int do_cli_server(int argc, char **argv TSRMLS_DC) /* {{{ */
                        fprintf(stderr, "Directory or script %s does not exist.\n", document_root);
                        return 1;
                }
+               if (!S_ISDIR(sb.st_mode)) {
+                       fprintf(stderr, "%s is not a directory.\n", document_root);
+                       return 1;
+               }
        } else {
                document_root = ".";
        }