Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2002:
[Freeciv-Dev] Re: servercrash (1.13.1-devel)
Home

[Freeciv-Dev] Re: servercrash (1.13.1-devel)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jason Short <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: servercrash (1.13.1-devel)
From: rf13@xxxxxxxxxxxxxxxxx
Date: Wed, 25 Sep 2002 03:05:48 -0700

On Tue, Sep 24, 2002 at 02:20:00PM -0500, Jason Short wrote:
> Thomas Strub wrote:
> 
> > civserver: dataio.c:342: dio_put_bit_string: Assertion `bytes < 255'
> > failed.
> 
> void dio_put_bit_string(struct data_out *dout, const char *value)
> {

>    size_t bits = strlen(value)

bits = 0 in the error case

> , bytes = (bits - 1) / 8 + 1;

bytes = -1/8 + 1 (you may expect that this will be 1 but it isn't if
it is calculated in size_t (an unsigned type). Then it is 2^32/8+1 =
2^24+1 = 16777217. Solution change the type of bytes to int.

>    assert(bytes < UCHAR_MAX);

>      dio_put_uint8(dout, bits);

> Perhaps I am missing something...but shouldn't the assertion be 
> assert(bits < UCHAR_MAX) instead?  Otherwise the 
> dio_put_uint8(dout,bits) line will fail.

Yes you are right.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx


[Prev in Thread] Current Thread [Next in Thread]