Remove trailing newline from error message in dlerror() on Windows
1. Add FORMAT_MESSAGE_MAX_WIDTH_MASK flag to remove trailing \r\n from the error message returned by FormatMessageA(). 2. Also, add FORMAT_MESSAGE_IGNORE_INSERTS to avoid potential problems with system messages that have argument placeholders. Quote from FormatMessage docs on MSDN: If this function is called without FORMAT_MESSAGE_IGNORE_INSERTS, the Arguments parameter must contain enough parameters to satisfy all insertion sequences in the message string, and they must be of the correct type. Therefore, do not use untrusted or unknown message strings with inserts enabled because they can contain more insertion sequences than Arguments provides, or those that may be of the wrong type. In particular, it is unsafe to take an arbitrary system error code returned from an API and use FORMAT_MESSAGE_FROM_SYSTEM without FORMAT_MESSAGE_IGNORE_INSERTS.
Showing
Please register or sign in to comment