Wireshark-dev: Re: [Wireshark-dev] packet_win.c still broken
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Tue, 25 Jun 2013 12:57:27 -0700
On Jun 25, 2013, at 12:27 PM, Joerg Mayer <jmayer@xxxxxxxxx> wrote:

> your change to the buffer handling broke packet_win.c when being built
> with WANT_PACKET_EDITOR.
> As I asked about this problem before, maybe this bug isn't worth fixing,
> but then we should remove WANT_PACKET_EDITOR.

It's not part of the standard build, so I didn't put it at the top of my priority list (which has a bunch of libpcap/tcpdump/Wireshark stuff on it, in addition to stuff unrelated to software).

Once I file my next clang bug, I'll look at fixing that one.

(clang bug: if anybody from the mothership is reading this, this code should *NOT* get warnings for the call to g_strdup_vprintf() when built with -Wformat-nonliteral:

test.h:

extern char *g_markup_vprintf_escaped(const char *format, va_list args)
    __attribute__((__format__(__printf__, 1, 0)));

extern char *g_strdup_vprintf(const char *format, va_list args)
    __attribute__((__format__(__printf__, 1, 0)));

test.c:

#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>

#include "test.h"

char *
g_strdup_vprintf_escaped(const char *format, va_list args)
{
        return g_strdup_vprintf(format, args);
}

char *
g_strdup_vprintf(const char *format, va_list args)
{
        char *result;

        result = malloc(1024);
        if (result == NULL)
                return NULL;
        vsnprintf(result, 1024, format, args);
        return result;
}

because calling g_strdup_vprintf_escaped() from a routine with compile-time format checking enabled is no more unsafe than calling g_strdup_vprintf() from a routine with compile-time format checking enabled, but clang complains about the former but not the latter.  It's as if g_strdup_vprintf()'s flavor of safety isn't inherited by the wrapper function.

But, as indicated above, a Radar is forthcoming.)