Author: rjung
Date: Thu Dec 25 18:36:11 2014
New Revision: 1647914
URL: http://svn.apache.org/r1647914
Log:
Add JK_MAX_NAME_SIZE define for maximal name
lengths (worker name, route, domain etc.).
Derive JK_SHM_STR_SZ from JK_MAX_NAME_SIZE.
Add JK_MAX_ATTRIBUTE_NAME_SIZE define and check
its correctness during startup.
Derive PARAM_BUFFER_SIZE from JK_MAX_NAME_SIZE
and JK_MAX_ATTRIBUTE_NAME_SIZE.
Docs for restriction coming from JK_MAX_NAME_SIZE
still needed. Note that this restriction was
already existing but more implicit.
I'll also add checks for correct length assumptions
in the worker validate functions.
Modified:
tomcat/jk/trunk/native/apache-1.3/mod_jk.c
tomcat/jk/trunk/native/apache-2.0/mod_jk.c
tomcat/jk/trunk/native/common/jk_global.h
tomcat/jk/trunk/native/common/jk_shm.h
tomcat/jk/trunk/native/common/jk_util.c
tomcat/jk/trunk/native/common/jk_util.h
tomcat/jk/trunk/native/iis/jk_isapi_plugin.c
Modified: tomcat/jk/trunk/native/apache-1.3/mod_jk.c
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/apache-1.3/mod_jk.c?rev=1647914&r1=1647913&r2=1647914&view=diff
==============================================================================
--- tomcat/jk/trunk/native/apache-1.3/mod_jk.c (original)
+++ tomcat/jk/trunk/native/apache-1.3/mod_jk.c Thu Dec 25 18:36:11 2014
@@ -2975,9 +2975,16 @@ static void jk_init(server_rec * s, ap_p
int rc;
server_rec *srv = s;
const char *err_string = NULL;
+ int remain;
jk_server_conf_t *conf =
(jk_server_conf_t *) ap_get_module_config(s->module_config,
&jk_module);
+ remain = jk_check_buffer_size();
+ if (remain < 0) {
+ jk_error_exit(APLOG_MARK, APLOG_EMERG, srv, p,
+ "mod_jk: JK_MAX_ATTRIBUTE_NAME_SIZE in jk_util.c too
small, "
+ "increase by %d", -1 * remain);
+ }
if (!jk_worker_properties)
jk_map_alloc(&jk_worker_properties);
jk_map_put(jk_worker_properties, "ServerRoot", ap_server_root, NULL);
Modified: tomcat/jk/trunk/native/apache-2.0/mod_jk.c
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/apache-2.0/mod_jk.c?rev=1647914&r1=1647913&r2=1647914&view=diff
==============================================================================
--- tomcat/jk/trunk/native/apache-2.0/mod_jk.c (original)
+++ tomcat/jk/trunk/native/apache-2.0/mod_jk.c Thu Dec 25 18:36:11 2014
@@ -3424,8 +3424,16 @@ static int jk_post_config(apr_pool_t * p
jk_server_conf_t *conf;
server_rec *srv = s;
const char *err_string = NULL;
+ int remain;
void *data = NULL;
+ remain = jk_check_buffer_size();
+ if (remain < 0) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s,
+ "mod_jk: JK_MAX_ATTRIBUTE_NAME_SIZE in jk_util.c too
small, "
+ "increase by %d", -1 * remain);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
apr_pool_userdata_get(&data, JK_LOG_LOCK_KEY, s->process->pool);
if (data == NULL) {
/* create the jk log lockfiles in the parent */
Modified: tomcat/jk/trunk/native/common/jk_global.h
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_global.h?rev=1647914&r1=1647913&r2=1647914&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_global.h (original)
+++ tomcat/jk/trunk/native/common/jk_global.h Thu Dec 25 18:36:11 2014
@@ -188,6 +188,8 @@ extern "C"
#define JK_LF (10)
#define JK_CR (13)
+#define JK_MAX_NAME_SIZE (60)
+
#define JK_SESSION_IDENTIFIER "JSESSIONID"
#define JK_PATH_SESSION_IDENTIFIER ";jsessionid"
Modified: tomcat/jk/trunk/native/common/jk_shm.h
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_shm.h?rev=1647914&r1=1647913&r2=1647914&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_shm.h (original)
+++ tomcat/jk/trunk/native/common/jk_shm.h Thu Dec 25 18:36:11 2014
@@ -42,7 +42,7 @@ extern "C"
#define JK_SHM_MAJOR '1'
#define JK_SHM_MINOR '3'
-#define JK_SHM_STR_SIZ 63
+#define JK_SHM_STR_SIZ (JK_ALIGN(JK_MAX_NAME_SIZE + 1, 8) - 1)
#define JK_SHM_MAGIC '!', 'J', 'K', 'S', 'H', 'M', JK_SHM_MAJOR,
JK_SHM_MINOR
#define JK_SHM_MAGIC_SIZ 8
Modified: tomcat/jk/trunk/native/common/jk_util.c
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_util.c?rev=1647914&r1=1647913&r2=1647914&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_util.c (original)
+++ tomcat/jk/trunk/native/common/jk_util.c Thu Dec 25 18:36:11 2014
@@ -129,12 +129,12 @@
#define LOG_BUFFER_SIZE 1024
/*
- * Our longest worker attribute name is about 30 bytes,
- * so 100 bytes for "worker." plus worker name plus "."
- * plus attribute names leaves at least 60 bytes for
- * the worker names. That should be enough.
+ * Our longest worker attribute name is below 30 bytes.
+ * Add space for "worker.", another ".", the
+ * worker name and the final '\0'.
*/
-#define PARAM_BUFFER_SIZE 100
+#define JK_MAX_ATTRIBUTE_NAME_SIZE (30)
+#define PARAM_BUFFER_SIZE (JK_MAX_NAME_SIZE + 8 + JK_MAX_ATTRIBUTE_NAME_SIZE +
1)
#define MAKE_WORKER_PARAM(P) \
{ \
size_t remain = PARAM_BUFFER_SIZE; \
@@ -1849,6 +1849,23 @@ int jk_is_deprecated_property(const char
}
return JK_FALSE;
}
+
+int jk_check_buffer_size()
+{
+ const char **props;
+ size_t len = 0;
+ size_t max_len = 0;
+
+ props = &supported_properties[0];
+ while (*props) {
+ len = strlen(*props);
+ if (len > max_len)
+ max_len = len;
+ props++;
+ }
+ return JK_MAX_ATTRIBUTE_NAME_SIZE - max_len;
+}
+
/*
* Check that property is a valid one (to prevent user typos).
* Only property starting with worker.
Modified: tomcat/jk/trunk/native/common/jk_util.h
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_util.h?rev=1647914&r1=1647913&r2=1647914&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_util.h (original)
+++ tomcat/jk/trunk/native/common/jk_util.h Thu Dec 25 18:36:11 2014
@@ -180,6 +180,8 @@ int jk_is_unique_property(const char *pr
int jk_is_deprecated_property(const char *prp_name);
+int jk_check_buffer_size();
+
int jk_is_valid_property(const char *prp_name);
int jk_get_worker_stdout(jk_map_t *m, const char *wname, const char
**stdout_name);
Modified: tomcat/jk/trunk/native/iis/jk_isapi_plugin.c
URL:
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/iis/jk_isapi_plugin.c?rev=1647914&r1=1647913&r2=1647914&view=diff
==============================================================================
--- tomcat/jk/trunk/native/iis/jk_isapi_plugin.c (original)
+++ tomcat/jk/trunk/native/iis/jk_isapi_plugin.c Thu Dec 25 18:36:11 2014
@@ -2943,8 +2943,15 @@ static int read_registry_init_data(void)
int ok = JK_FALSE;
LPVOID src;
HKEY hkey;
+ int remain;
jk_map_t *map = NULL;
+ remain = jk_check_buffer_size();
+ if (remain < 0) {
+ jk_log(logger, JK_LOG_ERROR,
+ "mod_jk: JK_MAX_ATTRIBUTE_NAME_SIZE in jk_util.c too small, "
+ "increase by %d", -1 * remain);
+ }
if (jk_map_alloc(&map)) {
if (jk_map_read_properties(map, jk_environment_map, ini_file_name,
NULL,
JK_MAP_HANDLE_DUPLICATES, logger)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]