fedora 23
format weakness #40


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.

File Name:



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


    String(const char *s) :
        buffer(s, s + strlen(s) + 1)

    String(const String &other) :

    template <class InputIterator>
    String(InputIterator first, InputIterator last) :
        buffer(first, last)

     * From a printf-like format string
    static String
    format(const char *format, ...)
#ifdef __GNUC__
    __attribute__ ((format (printf, 1, 2)))

        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); 

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.