Eggheads: core dump on solaris eggdrop, solution included

Bryan Drewery lordares at shatow.net
Mon Jun 20 14:28:48 CST 2005


This should be fixed in CVS, a patch about this was committed some months 
ago.

Give the CVS build a try and get back to us :)

Thanks.

------
Bryan Drewery


On Mon, 20 Jun 2005, Peter Johansson wrote:

> Hi!
>
> I have downloaded eggdrop 1.6.17 from ftp.eggheads.org and compiled it
> under Solaris 2.8, 2.9 and 2.10 (SunOS 5.8, 5.9 and 5.10) with gcc
> 3.4.3. The same problem shows up on all OS versions. The problem is
> that the bot dumps core when trying to share user files shortly after
> trying to botlink to the hub bot.
>
> By running gdb on the core file I found that the segmentation
> violation occurs in make_rand_str() which gets an erroneous string
> length (way too large). This happens when the bot generates a random
> password for the first time when it's linking to hub. It all boils
> down to randint() not working properly.
>
> I have verified that you get results out of range from randint() by
> using the tcl command rand.
>
> The problem is that RAND_MAX is 32767 which is max value that rand()
> returns, but random() is used and on Solaris random() will return an
> integer in the range 0 to 2**31 - 1.
>
> By modifying the definition of randint() macro in main.h, changing
> RAND_MAX to 2147483647 (=2**31 - 1) it works as intended and I get no
> core dumps. Specifically the change is to change the row
>
> #define randint(n) (unsigned long) (random() / (RAND_MAX + 1.0) * ((n)
> < 0 ? (-(n)) : (n)))
>
> into
>
> #define randint(n) (unsigned long) (random() / (2147483647 + 1.0) *
> ((n) < 0 ? (-(n)) : (n)))
>
> This problem can be solved by either including a check for Solaris
> when using random() and not use RAND_MAX or by simply using rand() all
> the time, or by
> masking the result from random() & RAND_MAX. I'm no portability expert so
> I'm sure you will find a good solution according to your taste. If anything is
> unclear about the problem description, don't be shy to ask.
>
> This problem also affects all other functions using randint or tcl command rand,
> which could be seen by for example auto-voice with random delay wasn't working
> (it never voiced, probably due to waiting several hundred thousands of seconds,
> instead of e.g. between 1 and 10 seconds).
>
> Please let me know if I misunderstood anything, and thanks for writing and
> supporting the eggdrop software.
>
> Best regards,
> dioid at EFNet
>



More information about the Eggheads mailing list