TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

Why bar() is more secure than foo()

Joe Duffy has an interesting article on secure exception handling (which I will call "why bar() is more secure than foo()". That is, of course, an oversimplification to avoid spoilers to the real article. :-)
 

void foo()

{

    // Impersonate

    try

    {

        // something causes an exception...

    }

    finally

    {

        // revert impersonation

    }

}

 

void bar()

{

    // Impersonate

    try

    {

        // something causes an exception...

    }

    catch

    {

        // revert impersonation

        throw;

    }

    finally

    {

        // revert impersonation

    }

}


Digg!

posted on Friday, January 14, 2005 12:13 PM

Feedback

No comments posted yet.