Ethereal-dev: Re: [Ethereal-dev] lemon.c strlen wrong type

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: Tue, 26 Jun 2001 13:55:46 -0700 (PDT)
> (there are other places where strlen is used, but they are 
> automatically cast down to the proper type.  When doing a 
> subroutine call, however, the type needed is (in theory).
> not really known.).

...if the argument in question is a varargs argument.  (If the argument
is one covered by a function prototype, the type needed is known, and
the conversion is done.)

> The solution I came up with was to cast the return value of
> strlen at the needed locations (and hope for no overflow!).

I checked in a change to cast the entire expression, instead.  (If
there's an overflow, that means that the string is *extremely* long; the
right fix there would be to check whether it's greater than "max-{whatever}",
and just provide 0 as the argument.)