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] Lemon crashing on Solaris? (was Re: [Wireshark-commits] buil

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Mon, 25 Nov 2013 10:40:36 -0800
On Nov 24, 2013, at 5:37 PM, Bálint Réczey <balint@xxxxxxxxxxxxxxx> wrote:

> I tried to trigger a crash using GCC and -ftrapv without success while
> the clang-compiled binary crashed as expected:

Reproduced with clang on (x86-64) OS X.

The problem is in

	PRIVATE int strhash(const char *x)
	{
	  int h = 0;
	  while( *x) h = h*13 + *(x++);
	  return h;
	}

In practice, the result of the hash function is taken modulo the hash table size, and that's always done with &, so, in practice, it's safe if it overflows.

Perhaps it should do the calculation with unsigned integers and return an unsigned integer, however.