Fix std::out_of_range exception with short filenames (Linux)
authorChase Miller <chase@bawxen.net>
Sat, 7 Feb 2015 03:04:39 +0000 (22:04 -0500)
committerChase Miller <chase@bawxen.net>
Sat, 7 Feb 2015 03:04:39 +0000 (22:04 -0500)
An unsigned integer was being used while scanning the CLR path to locate assemblies. If a file existed in the directory with a name shorter than the longest extension being checked for (.ni.dll), then the variable would underflow and cause an exception when used as an index on the filename.

src/coreclr/hosts/unixcorerun/corerun.cpp

index 2d5f129..0676267 100644 (file)
@@ -190,7 +190,7 @@ void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList)
             std::string filename(entry->d_name);
             
             // Check if the extension matches the one we are looking for
-            size_t extPos = filename.length() - extLength;
+            int extPos = filename.length() - extLength;
             if ((extPos <= 0) || (filename.compare(extPos, extLength, ext) != 0))
             {
                 continue;