From: Mike P. <mj...@fi...> - 2005-11-30 17:56:20
|
Hi all, I've been running into some segfaults with the CVS version and a JET3 database, and discovered a bug in read_pg_if_n in table.c. I've done so much futzing I can't be fussed to make a diff, but the change is easy enough - if you insert the bit between the 'MJP' comments as shown below, this will avoid the situation where cur_pos is outside the current page size, and hence causes 'half' to go negative. It's worked for me - I don't know how clean it is, or whether it's masking another error further up the line. As an aside, I've also got support for REPID's if anyone is interested - again, a couple of simple changes. Does anyone know if anything is making it into CVS, or has the maintainer gone awol ?? ------- guint16 read_pg_if_n(MdbHandle *mdb, void *buf, int *cur_pos, int len) { // MJP while (*cur_pos > mdb->fmt->pg_size) { mdb_read_pg(mdb, mdb_get_int32(mdb->pg_buf,4)); *cur_pos = *cur_pos - mdb->fmt->pg_size; } // MJP if (*cur_pos + len < mdb->fmt->pg_size) { memcpy(buf, &mdb->pg_buf[*cur_pos], len); return 0; } else { int half = mdb->fmt->pg_size - *cur_pos; //printf ("curpos = %d, pg_size = %d, len = %d, half = %d\n", *cur_pos, mdb->fmt->pg_size, len, half); memcpy(buf, &mdb->pg_buf[*cur_pos], half); mdb_read_pg(mdb, mdb_get_int32(mdb->pg_buf,4)); memcpy(buf + half, &mdb->pg_buf[8], len - half); *cur_pos = 8 - half; return 1; } } -- Cheers, Mike mj...@fi... http://www.filmsat59.com Films at 59 Ltd, 59 Cotham Hill, Bristol. BS6 6JR. UK +44 117 906 4300 |