argtable / argtable3

A single-file, ANSI C, command-line parsing library that parses GNU-style command-line options.
http://www.argtable.org
Other
372 stars 65 forks source link

Fixed format string misuse (V618) and not zero-terminated string (C6053) warnings in win32 'warnx' implementation #5

Closed ghost closed 9 years ago

ghost commented 9 years ago

Both warnings are false positive, since opterrmsg buffer is controled solely by the warnx function and _vsnprintf appears to be zero-terminating its output as the documentation says. I've changed the fprintf call so it guards from a formatting string input to make V618 of the PVS Studio happy, manually zeroed the buffer before _vsnprintf call and limited it's output size to (buffer size - 1) to guarantee the output is always zero-terminated despite the implementation and suppressed the warning C6053 of the VS Code Analysis.