ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] Passing NULL to %s format specifiers

From: Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>
Date: Wed, 15 Aug 2012 10:57:54 -0400
The problem with that is, at least in the backtrace I started that other thread with, that we're not calling strlen() ourselves but rather (in that case) vsnprintf() is. Technically we could LD_PRELOAD our wonderful strlen() in [on systems that support that], but as I mentioned, that would be Just Plain Nuts.

mmann78@xxxxxxxxxxxx wrote:
It's a bit clunky, but would ws_strlen() be a solution? Wrapping strlen() but ensuring the NULL check is done?
-----Original Message-----
From: Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>
To: Developer support list for Wireshark <wireshark-dev@xxxxxxxxxxxxx>
Sent: Wed, Aug 15, 2012 10:17 am
Subject: Re: [Wireshark-dev] Passing NULL to %s format specifiers

Evan Huus wrote:
On Linux and most other operating systems I know of, passing a NULL to
a %s format specifier is safe. On Solaris, as it turns out, it isn't
[1].

The case in the filed bug is fairly trivial to fix, but I'm wondering
if this is something that should be added to the Code Style /
Portability section of README.developer?

Alternatively, since I have no idea how many of these bugs we may have
to fix, perhaps we should be wrapping all format strings somehow?

Hopefully someone with some Solaris experience (or even a Solaris test
box) could weigh in, since I have neither.

For the record we last discussed this a little over a year ago:

http://www.wireshark.org/lists/wireshark-dev/201105/msg00202.html

As for adding something to the doc: sure but I doubt it'll help much.