diff --git a/libyara/modules/dotnet/dotnet.c b/libyara/modules/dotnet/dotnet.c index 2cfc82da..3e49acba 100644 --- a/libyara/modules/dotnet/dotnet.c +++ b/libyara/modules/dotnet/dotnet.c @@ -795,6 +795,9 @@ void dotnet_parse_tilde_2( // Now follow the Class index into the TypeRef table. typeref_row = typeref_ptr + (typeref_row_size * class_index); + + if (!fits_in_pe(pe, typeref_row, typeref_row_size)) + break; // Skip over the ResolutionScope and check the Name field, // which is an index into the Strings heap. diff --git a/tests/oss-fuzz/dotnet_fuzzer_corpus/clusterfuzz-testcase-minimized-dotnet_fuzzer-5195285818507264 b/tests/oss-fuzz/dotnet_fuzzer_corpus/clusterfuzz-testcase-minimized-dotnet_fuzzer-5195285818507264 new file mode 100644 index 00000000..0d308e15 Binary files /dev/null and b/tests/oss-fuzz/dotnet_fuzzer_corpus/clusterfuzz-testcase-minimized-dotnet_fuzzer-5195285818507264 differ