Skip to content

Instantly share code, notes, and snippets.

@AArnott
Created May 7, 2014 16:20
An example of a method that is vulnerable to RPC reentrancy.
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