[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Patch: Subtle defects in FormatMessageWrapper

From: Dmitry <wipedout_at_yandex.ru>
Date: Mon, 01 Feb 2010 17:16:03 +0300

Hey.

There're several issues with using FormatMessage() wrapper.

First of all, the wrapper is only suitable for one-time use. If CFormatMessageWrapper::release() is called from the second call to ObtainMessage() on an already initialized wrapper variable it will call LocalFree() which can alter global "last error", so the next message retrieval result will be plain wrong.

Also there're couple of sites where FormatMessage() is used without a wrapper, LPVOID is not initialized prior to FormatMessage() call and the return value of the latter is not checked either. So if FormatMessage() fails the LPVOID will be likely left uninitialized and program will run into undefined behaviour.

Patch addressing these issues follows.

Best wishes.
Dmitry.

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=757&dsMessageId=2443797

To unsubscribe from this discussion, e-mail: [dev-unsubscribe_at_tortoisesvn.tigris.org].

Received on 2010-02-01 15:16:22 CET

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.