Skip to content

Commit

Permalink
produce errors on duplicate known attributes in mono
Browse files Browse the repository at this point in the history
  • Loading branch information
VSadov committed Jan 22, 2022
1 parent f4beac6 commit 88625e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/libraries/System.Reflection/tests/AssemblyNameTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void Ctor_String_Public_Key(string name, string expectedName)
[InlineData("/a", typeof(FileLoadException))]
[InlineData(" ", typeof(FileLoadException))]
[InlineData(" \t \r \n ", typeof(FileLoadException))]
[InlineData("aa, culture=en-en, culture=en-en", typeof(FileLoadException))]
[InlineData("MyAssemblyName, PublicKey=00000000000000000400000000000000, PublicKeyToken=b77a5c561934e089", typeof(FileLoadException))]
public void Ctor_String_Invalid(string assemblyName, Type exceptionType)
{
Expand Down
26 changes: 17 additions & 9 deletions src/mono/mono/metadata/assembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -2544,7 +2544,7 @@ mono_assembly_name_parse_full (const char *name, MonoAssemblyName *aname, gboole
gchar *key_uq;
gchar *retargetable = NULL;
gchar *retargetable_uq;
gchar *procarch;
gchar *procarch = NULL;
gchar *procarch_uq;
gboolean res;
gchar *value, *part_name;
Expand Down Expand Up @@ -2590,43 +2590,47 @@ mono_assembly_name_parse_full (const char *name, MonoAssemblyName *aname, gboole

if (part_name_len == 7 && !g_ascii_strncasecmp (part_name, "Version", part_name_len)) {
*is_version_defined = TRUE;
version = value;
if (strlen (version) == 0) {
if (version != NULL || strlen (value) == 0) {
goto cleanup_and_fail;
}
version = value;
tmp++;
continue;
}

if (part_name_len == 7 && !g_ascii_strncasecmp (part_name, "Culture", part_name_len)) {
culture = value;
if (strlen (culture) == 0) {
if (culture != NULL || strlen (value) == 0) {
goto cleanup_and_fail;
}
culture = value;
tmp++;
continue;
}

if (part_name_len == 14 && !g_ascii_strncasecmp (part_name, "PublicKeyToken", part_name_len)) {
*is_token_defined = TRUE;
token = value;
if (strlen (token) == 0) {
if (token != NULL || key != NULL || strlen (value) == 0) {
goto cleanup_and_fail;
}
token = value;
tmp++;
continue;
}

if (part_name_len == 9 && !g_ascii_strncasecmp (part_name, "PublicKey", part_name_len)) {
key = value;
if (strlen (key) == 0) {
if (token != NULL || key != NULL || strlen (value) == 0) {
goto cleanup_and_fail;
}
key = value;
tmp++;
continue;
}

if (part_name_len == 12 && !g_ascii_strncasecmp (part_name, "Retargetable", part_name_len)) {
if (retargetable != NULL) {
goto cleanup_and_fail;
}

retargetable = value;
retargetable_uq = unquote (retargetable);
if (retargetable_uq != NULL)
Expand All @@ -2645,6 +2649,10 @@ mono_assembly_name_parse_full (const char *name, MonoAssemblyName *aname, gboole
}

if (part_name_len == 21 && !g_ascii_strncasecmp (part_name, "ProcessorArchitecture", part_name_len)) {
if (procarch != NULL) {
goto cleanup_and_fail;
}

procarch = value;
procarch_uq = unquote (procarch);
if (procarch_uq != NULL)
Expand Down

0 comments on commit 88625e5

Please sign in to comment.