fedora 23
format weakness #42


Weakness Breakdown


A format string exploit occurs when the data of an input string is evaluated as a command by the program. This class of attacks is very similar to buffer overflows since an attacker could execute code, read the stack or cause new behaviors that compromise security. Learn more about format string attacks on OWASP attack index.

Warning code(s):

If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always 0-terminate.

File Name:



The highlighted line of code below is the trigger point of this particular Fedora 23 format weakness.

         va_list args;

        va_start(args, format);

        int length;
        va_list args_copy;
        va_copy(args_copy, args);
#ifdef _WIN32
        /* We need to use _vscprintf to calculate the length as vsnprintf returns -1
         * if the number of characters to write is greater than count.
        length = _vscprintf(format, args_copy);
        char dummy;
        length = vsnprintf(&dummy, sizeof dummy, format, args_copy);

        assert(length >= 0);
        size_t size = length + 1;

        String path(size);

        va_start(args, format);
        vsnprintf(path.buf(), size, format, args);

        return path;

     * Conversion to ordinary C strings.

    const char *str(void) const {
        assert(buffer.back() == 0);
        return &buffer[0];

    operator const char *(void) const {
        return str();

     * Iterators

    typedef Buffer::const_iterator const_iterator;
    typedef Buffer::iterator iterator;

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.