You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2002/03/21 06:28:14 UTC
cvs commit: httpd-2.0/server gen_test_char.c util.c
wrowe 02/03/20 21:28:14
Modified: server gen_test_char.c util.c
Log:
Correct our list of escape characters to include percent and the
carriage return on Win32/OS2, and modify the \r \n escaping to account
for the fact that Win32/OS2 don't pass these characters through a true
argv[] mechansim; replace them with a whitespace since they effectively
are for most applications.
Revision Changes Path
1.11 +18 -0 httpd-2.0/server/gen_test_char.c
Index: gen_test_char.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/gen_test_char.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- gen_test_char.c 13 Mar 2002 20:48:00 -0000 1.10
+++ gen_test_char.c 21 Mar 2002 05:28:14 -0000 1.11
@@ -110,6 +110,24 @@
flags |= T_ESCAPE_PATH_SEGMENT;
}
+#if defined(WIN32) || defined(OS2)
+ /* Win32/OS2 have many of the same vulnerable characters
+ * as Unix sh, plus the carriage return and percent char.
+ * The proper escaping of these characters varies from unix
+ * since Win32/OS2 use carets or doubled-double quotes,
+ * and neither lf nor cr can be escaped. We escape unix
+ * specific as well, to assure that cross-compiled unix
+ * applications behave similiarly when invoked on win32/os2.
+ */
+ if (strchr("&;`'\"|*?~<>^()[]{}$\\\n\r%", c)) {
+ flags |= T_ESCAPE_SHELL_CMD;
+ }
+#else
+ if (strchr("&;`'\"|*?~<>^()[]{}$\\\n", c)) {
+ flags |= T_ESCAPE_SHELL_CMD;
+ }
+#endif
+
if (!apr_isalnum(c) && !strchr("$-_.+!*'(),:@&=/~", c)) {
flags |= T_OS_ESCAPE_PATH;
}
1.122 +10 -7 httpd-2.0/server/util.c
Index: util.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/util.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -r1.121 -r1.122
--- util.c 13 Mar 2002 20:48:00 -0000 1.121
+++ util.c 21 Mar 2002 05:28:14 -0000 1.122
@@ -1454,12 +1454,15 @@
for (; *s; ++s) {
#if defined(OS2) || defined(WIN32)
- /* Don't allow '&' in parameters under OS/2. */
- /* This can be used to send commands to the shell. */
- if (*s == '&') {
- *d++ = ' ';
- continue;
- }
+ /*
+ * Newlines to Win32/OS2 CreateProcess() are ill advised.
+ * Convert them to spaces since they are effectively white
+ * space to most applications
+ */
+ if (*s == '\r' || *s == '\n') {
+ *d++ = ' ';
+ continue;
+ }
#endif
if (TEST_CHAR(*s, T_ESCAPE_SHELL_CMD)) {
@@ -1498,7 +1501,7 @@
* Failure is due to
* bad % escape returns HTTP_BAD_REQUEST
*
- * decoding %00 -> \0
+ * decoding %00 -> \0 (the null character)
* decoding %2f -> / (a special character)
* returns HTTP_NOT_FOUND
*/