Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] strlen() and NULL pointer checks

From: Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>
Date: Mon, 16 May 2011 17:18:17 -0400
Chris Maynard wrote:
Jeff Morriss <jeff.morriss.ws@...> writes:

Is there a better way?  Or better yet, a proper solution?

Not claiming this is better or proper, just another alternative:

epan/strutil.c:

#include <string.h>
size_t ws_strlen(const char *s)
{
    if (s == NULL)
        return 0;
    return strlen(s);
}

But this won't work unless we can somehow force vsnprintf() and friends to use ws_strlen(). LD_PRELOAD will let you do that [on systems that support it], but nobody in their right mind uses LD_PRELOAD for production code (I hope).