From: Jim Ma Date: Sat, 8 Apr 2017 16:43:47 +0000 (+0800) Subject: Exit gracefully when running ildasm -nat against unsupported ni file. (dotnet/coreclr... X-Git-Tag: submit/tizen/20210909.063632~11030^2~7352 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69df3b3c80b3a021f160d2788ad39200adac3a47;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Exit gracefully when running ildasm -nat against unsupported ni file. (dotnet/coreclr#10821) ildasm -nat only works for fragile native images (ie CoreLib only by default). Running ildasm -nat against unsupported native images would cause a segmentation fault. This PR checks pNativeHeader->Signature == CORCOMPILE_SIGNATURE and end the program with a meaningful error message. fix dotnet/coreclr#10247 Commit migrated from https://github.com/dotnet/coreclr/commit/20248521af31e2307fcd728f1ebbf7877bb5ee59 --- diff --git a/src/coreclr/src/ildasm/dasm.cpp b/src/coreclr/src/ildasm/dasm.cpp index 68cfa2a..3d172f0 100644 --- a/src/coreclr/src/ildasm/dasm.cpp +++ b/src/coreclr/src/ildasm/dasm.cpp @@ -7370,6 +7370,13 @@ BOOL DumpFile() } CORCOMPILE_HEADER * pNativeHeader; g_pPELoader->getVAforRVA(VAL32(g_CORHeader->ManagedNativeHeader.VirtualAddress), (void**)&pNativeHeader); + + if (pNativeHeader->Signature != CORCOMPILE_SIGNATURE) + { + printError( g_pFile, "/native only works on NGen images." ); + goto exit; + } + g_pPELoader->getVAforRVA(VAL32(pNativeHeader->ManifestMetaData.VirtualAddress), &g_pMetaData); g_cbMetaData = VAL32(pNativeHeader->ManifestMetaData.Size); }