OSDN Git Service

* Added valid_* functions.
authorkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Mon, 24 Mar 2008 13:51:33 +0000 (13:51 +0000)
committerkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Mon, 24 Mar 2008 13:51:33 +0000 (13:51 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/branches/RELEASE_0_10_0@1919 1a406e8e-add9-4483-a2c8-d8cac5b7c224

configure
include/config.h
src/chxj_cookie.c

index 8ae3191..7412539 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for mod_chxj 0.9.0-1.
+# Generated by GNU Autoconf 2.61 for mod_chxj 0.9.1-1.
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
 # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@@ -726,8 +726,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='mod_chxj'
 PACKAGE_TARNAME='mod_chxj'
-PACKAGE_VERSION='0.9.0-1'
-PACKAGE_STRING='mod_chxj 0.9.0-1'
+PACKAGE_VERSION='0.9.1-1'
+PACKAGE_STRING='mod_chxj 0.9.1-1'
 PACKAGE_BUGREPORT=''
 
 ac_unique_file="src/mod_chxj.c"
@@ -1405,7 +1405,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures mod_chxj 0.9.0-1 to adapt to many kinds of systems.
+\`configure' configures mod_chxj 0.9.1-1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1476,7 +1476,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of mod_chxj 0.9.0-1:";;
+     short | recursive ) echo "Configuration of mod_chxj 0.9.1-1:";;
    esac
   cat <<\_ACEOF
 
@@ -1591,7 +1591,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-mod_chxj configure 0.9.0-1
+mod_chxj configure 0.9.1-1
 generated by GNU Autoconf 2.61
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1605,7 +1605,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by mod_chxj $as_me 0.9.0-1, which was
+It was created by mod_chxj $as_me 0.9.1-1, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   $ $0 $@
@@ -2423,7 +2423,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE=mod_chxj
- VERSION=0.9.0-1
+ VERSION=0.9.1-1
 
 
 cat >>confdefs.h <<_ACEOF
@@ -21824,7 +21824,7 @@ exec 6>&1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by mod_chxj $as_me 0.9.0-1, which was
+This file was extended by mod_chxj $as_me 0.9.1-1, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -21877,7 +21877,7 @@ Report bugs to <bug-autoconf@gnu.org>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-mod_chxj config.status 0.9.0-1
+mod_chxj config.status 0.9.1-1
 configured by $0, generated by GNU Autoconf 2.61,
   with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
index 13ebe3b..02be4b4 100644 (file)
 #define PACKAGE_NAME "mod_chxj"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "mod_chxj 0.9.0-1"
+#define PACKAGE_STRING "mod_chxj 0.9.1-1"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "mod_chxj"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "0.9.0-1"
+#define PACKAGE_VERSION "0.9.1-1"
 
 /* Define to 1 if you have the ANSI C header files. */
 #define STDC_HEADERS 1
 
 /* Version number of package */
-#define VERSION "0.9.0-1"
+#define VERSION "0.9.1-1"
 
 /* Define to empty if `const' does not conform to ANSI C. */
 /* #undef const */
index f092366..c9b4c07 100644 (file)
 
 static char* s_get_hostname_from_url(request_rec* r, char* value);
 static char* s_cut_until_end_hostname(request_rec*, char* value);
+static int valid_domain(request_rec *r, const char *value);
+static int valid_path(request_rec *r, const char *value);
+static int valid_expire(request_rec *r, const char *value);
+static int valid_secure(request_rec *r, const char *value);
+static int check_valid_cookie_attribute(request_rec *r, const char *pair);
+
 
 static char *
 alloc_cookie_id(request_rec *r)
@@ -639,17 +645,22 @@ chxj_load_cookie(request_rec* r, char* cookie_id)
         *val++ = 0;
         apr_table_add(load_cookie_table, key, val);
       }
-      tmp_sem = strchr(pair, ';'); 
+      tmp_pair = apr_pstrdup(r->pool, pair);
+      tmp_sem = strchr(tmp_pair, ';'); 
       if (tmp_sem)
         *tmp_sem = '\0';
 
-      if (strlen(header_cookie)) 
-        header_cookie = apr_pstrcat(r->pool, header_cookie, ";", NULL);
-
-      header_cookie = apr_pstrcat(r->pool, header_cookie, pair, NULL);
+      if (check_valid_cookie_attribute(r, pair)) {
+        if (strlen(header_cookie)) 
+          header_cookie = apr_pstrcat(r->pool, header_cookie, ";", NULL);
+  
+        header_cookie = apr_pstrcat(r->pool, header_cookie, tmp_pair, NULL);
+      }
     }
-    if (strlen(header_cookie))
+    if (strlen(header_cookie)) {
+      DBG(r, "ADD COOKIE to REQUEST HEADER:[%s]", header_cookie);
       apr_table_add(r->headers_in, "Cookie", header_cookie);
+    }
   
     cookie->cookie_headers = (apr_array_header_t*)apr_table_elts(load_cookie_table);
 
@@ -692,6 +703,102 @@ on_error0:
   return NULL;
 }
 
+static int
+check_valid_cookie_attribute(request_rec *r, const char *value)
+{
+  char *pstat;
+  char *pair;
+  char *first_pair;
+  char *domain_pair;
+  char *path_pair;
+  char *expire_pair;
+  char *secure_pair;
+
+  DBG(r, "start check_valid_cookie_attribute() value:[%s]", value);
+
+  domain_pair = path_pair = expire_pair = secure_pair = NULL;
+
+  /* pass first pair */
+  first_pair = apr_strtok(value, ";", &pstat);  
+
+  for (;;) {
+    pair = apr_strtok(NULL, ";", &pstat);
+    if (! pair) break;
+    pair = qs_trim_string(r, pair);
+    if (STRNCASEEQ('d','D',"domain", pair, sizeof("domain")-1)) {
+      domain_pair = apr_pstrdup(r->pool, pair);
+    }
+    else if (STRNCASEEQ('p','P',"path", pair, sizeof("path")-1)) {
+      path_pair = apr_pstrdup(r->pool, pair);
+    }
+    else if (STRNCASEEQ('e','E',"expire", pair, sizeof("expire")-1)) {
+      expire_pair = apr_pstrdup(r->pool, pair);
+    }
+    else if (STRNCASEEQ('s','S',"secure", pair, sizeof("secure")-1)) {
+      secure_pair = apr_pstrdup(r->pool, pair);
+    }
+  }
+
+  if (domain_pair) {
+    if (!valid_domain(r, domain_pair)) {
+      DBG(r, "invalid domain. domain_pair:[%s]", domain_pair);
+      return CHXJ_FALSE;
+    }
+  }
+  if (path_pair) {
+    if (!valid_path(r, path_pair)) {
+      DBG(r, "invalid path. path_pair:[%s]", path_pair);
+      return CHXJ_FALSE;
+    }
+  }
+  if (expire_pair) {
+    if (!valid_expire(r, expire_pair)) {
+      DBG(r, "invalid expire. expire_pair:[%s]", expire_pair);
+      return CHXJ_FALSE;
+    }
+  }
+  if (secure_pair) {
+    if (!valid_secure(r, secure_pair)) {
+      DBG(r, "invalid secure. secure_pair:[%s]", secure_pair);
+      return CHXJ_FALSE;
+    }
+  }
+  DBG(r, "end check_valid_cookie_attribute() value:[%s]", value);
+  return CHXJ_TRUE;
+}
+
+static int
+valid_domain(request_rec *r, const char *value)
+{
+  DBG(r, "start valid_domain() value:[%s]", value);
+  DBG(r, "end valid_domain() value:[%s]", value);
+  return CHXJ_TRUE;
+}
+
+static int
+valid_path(request_rec *r, const char *value)
+{
+  DBG(r, "start valid_path() value:[%s]", value);
+  DBG(r, "end valid_path() value:[%s]", value);
+  return CHXJ_TRUE;
+}
+
+static int
+valid_expire(request_rec *r, const char *value)
+{
+  DBG(r, "start valid_expire() value:[%s]", value);
+  DBG(r, "end valid_expire() value:[%s]", value);
+  return CHXJ_TRUE;
+}
+
+static int
+valid_secure(request_rec *r, const char *value)
+{
+  DBG(r, "start valid_secure() value:[%s]", value);
+  DBG(r, "end valid_secure() value:[%s]", value);
+  return CHXJ_TRUE;
+}
+
 
 char*
 chxj_add_cookie_parameter(request_rec* r, char* value, cookie_t* cookie)