rse 99/01/01 12:27:48
Modified: src CHANGES
src/include ap_mmn.h http_config.h
src/modules/standard mod_so.c
Log:
Added MODULE_MAGIC_COOKIE as the first field in a module structure to
allow us to distinguish between a garbled DSO (or even a file which isn't
an Apache module DSO at all) and a DSO which doesn't match the current
Apache API.
Submitted by: Ralf S. Engelschall
PR: 3152
Revision Changes Path
1.1188 +5 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.1187
retrieving revision 1.1188
diff -u -r1.1187 -r1.1188
--- CHANGES 1999/01/01 19:50:20 1.1187
+++ CHANGES 1999/01/01 20:27:45 1.1188
@@ -1,4 +1,9 @@
Changes with Apache 1.3.4
+
+ *) Added MODULE_MAGIC_COOKIE as the first field in a module structure to
+ allow us to distinguish between a garbled DSO (or even a file which
isn't
+ an Apache module DSO at all) and a DSO which doesn't match the current
+ Apache API. [Ralf S. Engelschall] PR#3152
*) Two minor enhancements to mod_rewrite: First RewriteRule now also
supports the ``nocase|NC'' flag (as RewriteCond already does for ages)
to
1.17 +3 -0 apache-1.3/src/include/ap_mmn.h
Index: ap_mmn.h
===================================================================
RCS file: /home/cvs/apache-1.3/src/include/ap_mmn.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ap_mmn.h 1999/01/01 19:04:39 1.16
+++ ap_mmn.h 1999/01/01 20:27:47 1.17
@@ -193,7 +193,10 @@
* 19981229 - mod_negotiation overhaul -- added ap_make_etag()
* and added vlist_validator to request_rec.
* 19990101 - renamed macro escape_uri() to ap_escape_uri()
+ * - Added MODULE_MAGIC_COOKIE to identify module
structures
*/
+
+#define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 19990101
1.99 +6 -1 apache-1.3/src/include/http_config.h
Index: http_config.h
===================================================================
RCS file: /home/cvs/apache-1.3/src/include/http_config.h,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- http_config.h 1999/01/01 19:04:40 1.98
+++ http_config.h 1999/01/01 20:27:47 1.99
@@ -186,6 +186,10 @@
*/
typedef struct module_struct {
+ unsigned long magic; /* Magic Cookie to identify a module
structure;
+ * It's mainly important for the DSO facility
+ * (see also mod_so).
+ */
int version; /* API version, *not* module version;
* check that module is compatible with this
* version of the server.
@@ -281,7 +285,8 @@
* signal an error). See src/include/ap_mmn.h for MMN version history.
*/
-#define STANDARD_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
+#define STANDARD_MODULE_STUFF MODULE_MAGIC_COOKIE, \
+ MODULE_MAGIC_NUMBER_MAJOR, \
MODULE_MAGIC_NUMBER_MINOR, \
-1, \
__FILE__, \
1.29 +12 -2 apache-1.3/src/modules/standard/mod_so.c
Index: mod_so.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_so.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- mod_so.c 1999/01/01 19:05:13 1.28
+++ mod_so.c 1999/01/01 20:27:48 1.29
@@ -247,11 +247,21 @@
* symbol name.
*/
if (!(modp = (module *)(ap_os_dso_sym(modhandle, modname)))) {
- return ap_pstrcat(cmd->pool, "Can't find module ", modname,
- " in file ", filename, ":", ap_os_dso_error(), NULL);
+ return ap_pstrcat(cmd->pool, "Can't locate API module structure `",
modname,
+ "' in file ", szModuleFile, ": ", ap_os_dso_error(),
NULL);
}
modi->modp = modp;
modp->dynamic_load_handle = modhandle;
+
+ /*
+ * Make sure the found module structure is really a module structure
+ *
+ */
+ if (modp->magic != MODULE_MAGIC_COOKIE) {
+ return ap_pstrcat(cmd->pool, "API module structure `", modname,
+ "' in file ", szModuleFile, " is garbled -"
+ " perhaps this is not an Apache module DSO?",
NULL);
+ }
/*
* Add this module to the Apache core structures