wrowe 02/03/21 22:06:26
Modified: file_io/win32 filesys.c
include apr.h.in apr.hnw apr.hw apr_thread_proc.h
include/arch/win32 fileio.h
Log:
Address several issues. c_is_fnchar must be namespace protected [for
linkage, not for external use], and this patch expands its use to
include IS_SHCHAR() tests for apr_thread_proc.c in Win32.
Also introduce apr_proc_t ->invoked member --- for logging or audit
purposes alone, for platforms that create a single 'command' string.
This doesn't adversly impact portability [have APR_HAS_PROC_INVOKED
feature macro to assure other platforms don't struggle with it] but
helps us measure portability when attempting to emulate execxx()
behavior on Win32 [and perhaps OS2 at some point.)
Revision Changes Path
1.8 +17 -9 apr/file_io/win32/filesys.c
Index: filesys.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/filesys.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- filesys.c 13 Mar 2002 20:39:12 -0000 1.7
+++ filesys.c 22 Mar 2002 06:06:26 -0000 1.8
@@ -76,15 +76,23 @@
* Oddly, \x7f _is_ acceptable ;)
*/
-const char c_is_fnchar[256] =
-{/* Reject all ctrl codes... */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- /* " * / : < > ? */
- 1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,0, 1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,
- /* \ */
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,
- /* | */
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,
+/* apr_c_is_fnchar[] maps Win32's file name and shell escape symbols
+ *
+ * element & 1 == valid file name character [excluding delimiters]
+ * element & 2 == character should be shell (caret) escaped from cmd.exe
+ *
+ * this must be in-sync with Apache httpd's gen_test_char.c for cgi escaping.
+ */
+
+const char apr_c_is_fnchar[256] =
+{/* Reject all ctrl codes... Escape \n and \r (ascii 10 and 13) */
+ 0,0,0,0,0,0,0,0,0,0,2,0,0,2,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ /* ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
+ 1,1,2,1,3,3,3,3,3,3,2,1,1,1,1,0, 1,1,1,1,1,1,1,1,1,1,0,3,2,1,2,2,
+ /* @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ */
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,3,2,3,3,1,
+ /* ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ */
+ 3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,3,2,3,3,1,
/* High bit codes are accepted (subject to utf-8->Unicode xlation) */
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1.104 +1 -0 apr/include/apr.h.in
Index: apr.h.in
===================================================================
RCS file: /home/cvs/apr/include/apr.h.in,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -r1.103 -r1.104
--- apr.h.in 16 Mar 2002 18:42:00 -0000 1.103
+++ apr.h.in 22 Mar 2002 06:06:26 -0000 1.104
@@ -138,6 +138,7 @@
#define APR_HAS_DSO @aprdso@
#define APR_HAS_SO_ACCEPTFILTER @acceptfilter@
#define APR_HAS_UNICODE_FS 0
+#define APR_HAS_PROC_INVOKED 0
#define APR_HAS_USER 1
#define APR_HAS_LARGE_FILES 0
#define APR_HAS_XTHREAD_FILES 0
1.11 +1 -0 apr/include/apr.hnw
Index: apr.hnw
===================================================================
RCS file: /home/cvs/apr/include/apr.hnw,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- apr.hnw 16 Mar 2002 18:42:00 -0000 1.10
+++ apr.hnw 22 Mar 2002 06:06:26 -0000 1.11
@@ -200,6 +200,7 @@
#define APR_HAS_DSO 1
#define APR_HAS_SO_ACCEPTFILTER 0
#define APR_HAS_UNICODE_FS 0
+#define APR_HAS_PROC_INVOKED 0
#define APR_HAS_USER 1
#define APR_HAS_LARGE_FILES 0
#define APR_HAS_XTHREAD_FILES 0
1.92 +1 -0 apr/include/apr.hw
Index: apr.hw
===================================================================
RCS file: /home/cvs/apr/include/apr.hw,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- apr.hw 16 Mar 2002 18:42:00 -0000 1.91
+++ apr.hw 22 Mar 2002 06:06:26 -0000 1.92
@@ -284,6 +284,7 @@
#define APR_HAS_DSO 1
#define APR_HAS_SO_ACCEPTFILTER 0
#define APR_HAS_UNICODE_FS 1
+#define APR_HAS_PROC_INVOKED 1
#ifndef _WIN32_WCE
#define APR_HAS_SENDFILE 1
#define APR_HAS_USER 1
1.85 +9 -3 apr/include/apr_thread_proc.h
Index: apr_thread_proc.h
===================================================================
RCS file: /home/cvs/apr/include/apr_thread_proc.h,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- apr_thread_proc.h 14 Mar 2002 22:18:16 -0000 1.84
+++ apr_thread_proc.h 22 Mar 2002 06:06:26 -0000 1.85
@@ -160,9 +160,15 @@
apr_file_t *out;
/** Parent's side of pipe to child's stdouterr */
apr_file_t *err;
-#ifdef WIN32
- /** Must retain the handle as any clone may not have the
- * the same permissions
+#if APR_HAS_PROC_INVOKED || defined(DOXYGEN)
+ /** Diagnositics/debugging string of the command invoked for
+ * this process [only present if APR_HAS_PROC_INVOKED is true]
+ */
+ char *invoked;
+#endif
+#if defined(WIN32) || defined(DOXYGEN)
+ /** Win32 specific: Must retain the creator's handle granting
+ * access, as a new copy may not grant the same permissions
*/
HANDLE hproc;
#endif
1.66 +6 -3 apr/include/arch/win32/fileio.h
Index: fileio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/win32/fileio.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- fileio.h 20 Mar 2002 08:54:43 -0000 1.65
+++ fileio.h 22 Mar 2002 06:06:26 -0000 1.66
@@ -233,11 +233,14 @@
};
};
-/* There are many goofy characters we can't accept. Here's the list.
+/* There are many goofy characters the filesystem can't accept
+ * or can confound the cmd.exe shell. Here's the list
+ * [declared in filesys.c]
*/
-extern const char c_is_fnchar[256];
+extern const char apr_c_is_fnchar[256];
-#define IS_FNCHAR(c) c_is_fnchar[(unsigned char)c]
+#define IS_FNCHAR(c) (apr_c_is_fnchar[(unsigned char)(c)] & 1)
+#define IS_SHCHAR(c) (apr_c_is_fnchar[(unsigned char)(c)] & 2 == 2)
/* If the user passes APR_FILEPATH_TRUENAME to either