Ethereal-dev: Re: [ethereal-dev] packet-snmp.c patch to handle zero length context names

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxxxxx>
Date: Sat, 1 Jul 2000 22:24:55 -0700
On Thu, Jun 29, 2000 at 02:16:29PM +0200, Juergen Schoenwaelder wrote:
> Assuming that ANSI C says a NULL is valid if the length in "%.*s" is
> zero, then the "%.*s" seems the right solution. Unfortunately, the
> replacement snprintf implementation which is shipped with ethereal
> crashes if you do that. (I am running things right now on Solaris
> 5.5.1 which does not have its own snprintf and friends).

I guess it's just trying to be compatible with Solaris "sprintf()",
which panics if you do

	sprintf("%.*s\n", 0, NULL);

(at least on Solaris 7 - the joys of a quad-boot PC).

My ANSI C spec is at work, but, even if ANSI C says the "*printf" are
not *supposed* to dereference the string pointer argument to "%.*s" if
the count argument is zero, that doesn't mean we should assume ANSI C
compliance, as, if the spec says that, Solaris 7's libraries aren't
compliant.

As noted, there's more than just the one "snprintf()" you found that
needs fixing; I'll fix all of them.