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]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: servercrash (1.13.1-devel)
From: Jason Short <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 24 Sep 2002 14:20:00 -0500

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), bytes = (bits - 1) / 8 + 1;

  assert(bytes < UCHAR_MAX);

  if (enough_space(dout, bytes + 1)) {
    size_t i;

    dio_put_uint8(dout, bits);

    for (i = 0; i < bits;) {
      int bit, data = 0;

      for (bit = 0; bit < 8 && i < bits; bit++, i++) {
        if (value[i] == '1') {
          data |= (1 << bit);
        }
      }
      dio_put_uint8(dout, data);
    }
  }
}

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.

Seems like the best solution is to make the length field either 16 or 32 bytes long. But this will break network compatability unless something clever is done...

jason



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