Mitigate Baron SameEdit (CVE-2021-3156) vulnerability

fedora 24
format weakness #45


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 24 format weakness.

     r[size] = 0;
    return r;

/* Change the allocator */
void avahi_set_allocator(const AvahiAllocator *a) {
    allocator = a;

char *avahi_strdup_vprintf(const char *fmt, va_list ap) {
    size_t len = 80;
    char *buf;


    if (!(buf = avahi_malloc(len)))
        return NULL;

    for (;;) {
        int n;
        char *nbuf;
        va_list ap2;

        va_copy (ap2, ap);
        n = vsnprintf(buf, len, fmt, ap2);
        va_end (ap2);

        if (n >= 0 && n < (int) len)
            return buf;

        if (n >= 0)
            len = n+1;
            len *= 2;

        if (!(nbuf = avahi_realloc(buf, len))) {
            return NULL;

        buf = nbuf;

char *avahi_strdup_printf(const char *fmt, ... ) {
    char *s;
    va_list ap;


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.