If mono is compiled without DISABLE_STRICT_STRONG_NAMES, but someone passes
--assembly-loader=legacy at runtime, give them the lax strong name
checking behavior (a candidate assembly is good as long as the name is right, but ignoring
the public key token and version).
MonoAssemblyCandidatePredicate predicate = NULL;
void* predicate_ud = NULL;
#if !defined(DISABLE_STRICT_STRONG_NAMES)
MonoAssemblyCandidatePredicate predicate = NULL;
void* predicate_ud = NULL;
#if !defined(DISABLE_STRICT_STRONG_NAMES)
- predicate = &mono_assembly_candidate_predicate_sn_same_name;
- predicate_ud = aname;
+ if (G_LIKELY (mono_loader_get_strict_strong_names ())) {
+ predicate = &mono_assembly_candidate_predicate_sn_same_name;
+ predicate_ud = aname;
+ }
#endif
if (domain->search_path && domain->search_path [0] != NULL) {
if (mono_trace_is_traced (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY)) {
#endif
if (domain->search_path && domain->search_path [0] != NULL) {
if (mono_trace_is_traced (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY)) {
MonoAssemblyCandidatePredicate predicate = NULL;
void* predicate_ud = NULL;
#if !defined(DISABLE_STRICT_STRONG_NAMES)
MonoAssemblyCandidatePredicate predicate = NULL;
void* predicate_ud = NULL;
#if !defined(DISABLE_STRICT_STRONG_NAMES)
- predicate = &mono_assembly_candidate_predicate_sn_same_name;
- predicate_ud = aname;
+ if (G_LIKELY (mono_loader_get_strict_strong_names ())) {
+ predicate = &mono_assembly_candidate_predicate_sn_same_name;
+ predicate_ud = aname;
+ }
#endif
len = strlen (aname->name);
#endif
len = strlen (aname->name);
void
mono_ginst_get_desc (GString *str, MonoGenericInst *ginst);
void
mono_ginst_get_desc (GString *str, MonoGenericInst *ginst);
+void
+mono_loader_set_strict_strong_names (gboolean enabled);
+
+gboolean
+mono_loader_get_strict_strong_names (void);
+
#endif /* __MONO_METADATA_INTERNALS_H__ */
#endif /* __MONO_METADATA_INTERNALS_H__ */
+/* If TRUE (but also see DISABLE_STICT_STRONG_NAMES #define), Mono will check
+ * that the public key token and version of a candidate assembly matches the
+ * requested strong name. If FALSE, as long as the name matches, the candidate
+ * will be allowed.
+ */
+static gboolean check_strong_names_strictly = TRUE;
+
// Amount initially reserved in each imageset's mempool.
// FIXME: This number is arbitrary, a more practical number should be found
#define INITIAL_IMAGE_SET_SIZE 1024
// Amount initially reserved in each imageset's mempool.
// FIXME: This number is arbitrary, a more practical number should be found
#define INITIAL_IMAGE_SET_SIZE 1024
+
+void
+mono_loader_set_strict_strong_names (gboolean enabled)
+{
+ check_strong_names_strictly = enabled;
+}
+
+gboolean
+mono_loader_get_strict_strong_names (void)
+{
+ return check_strong_names_strictly;
+}
} else if (strcmp (argv [i], "--nacl-null-checks-off") == 0){
nacl_null_checks_off = TRUE;
#endif
} else if (strcmp (argv [i], "--nacl-null-checks-off") == 0){
nacl_null_checks_off = TRUE;
#endif
+ } else if (strncmp (argv [i], "--assembly-loader=", strlen("--assembly-loader=")) == 0) {
+ gchar *arg = argv [i] + strlen ("--assembly-loader=");
+ if (strcmp (arg, "strict") == 0)
+ mono_loader_set_strict_strong_names (TRUE);
+ else if (strcmp (arg, "legacy") == 0)
+ mono_loader_set_strict_strong_names (FALSE);
+ else
+ fprintf (stderr, "Warning: unknown argument to --assembly-loader. Should be \"strict\" or \"legacy\"\n");
} else if (strncmp (argv [i], MONO_HANDLERS_ARGUMENT, MONO_HANDLERS_ARGUMENT_LEN) == 0) {
//Install specific custom handlers.
if (!mono_runtime_install_custom_handlers (argv[i] + MONO_HANDLERS_ARGUMENT_LEN)) {
} else if (strncmp (argv [i], MONO_HANDLERS_ARGUMENT, MONO_HANDLERS_ARGUMENT_LEN) == 0) {
//Install specific custom handlers.
if (!mono_runtime_install_custom_handlers (argv[i] + MONO_HANDLERS_ARGUMENT_LEN)) {