Created
May 7, 2014 16:20
An example of a method that is vulnerable to RPC reentrancy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int m_filesOpened; | |
private const int MaxOpenFilesAllowed = 2; | |
private FileStream[] m_openFiles = new FileStream[MaxOpenFilesAllowed]; | |
public int SomeMethod(string path) | |
{ | |
ThreadHelper.ThrowIfNotOnUIThread(); | |
if (m_filesOpened < MaxOpenFilesAllowed) | |
{ | |
m_openFiles[m_filesOpened] = File.Open(path, FileMode.Open); | |
m_filesOpened++; | |
return VSConstants.S_OK; | |
} | |
else | |
{ | |
return VSConstants.E_UNEXPECTED; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment