Ethereal-dev: Re: [Ethereal-dev] Crash around 2199 of gtk/main.c with bad command line flags

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

From: Guy Harris <guy@xxxxxxxxxx>
Date: Wed, 29 May 2002 17:49:13 -0700
On Thu, May 30, 2002 at 11:07:04AM +0930, Richard Sharpe wrote:
>   ethereal -m -r xxx.cap
> 
> causes a crash. 

Unfortunately,

	ethereal -m -r xxx.cap

is interpreted by "getopt()" as having one command-line flag argument,
"-m", the argument to which is "-r".  To quote the Solaris "getopt(3c)"
man page:

     The getopt() function does not  fully  check  for  mandatory
     arguments; that is, given an option string a:b and the input
     -a -b, getopt() assumes that -b is the mandatory argument to
     the  -a  option and not that -a is missing a mandatory argu-
     ment.

I.e., the command is interpreted as a request to open "xxx.cap" (because
recent versions of Ethereal treat the first non-flag command-line
argument as a file to open; that lets Ethereal be associated with file
types on desktops such as Windows, KDE, and possibly others), using "-r"
as the fixed-width text font.

Unfortunately, the code that tried to find the boldface version of the
text font assumed that a font name that begins with "-" is an XLFD font
name, and dumped core if the "weight" field was missing.

I've checked in a fix - now, instead of dumping core, it just fails to
find the font named "-r" and punts to the "fixed" font (without even
trying to find the boldface version "-rbold").