Crash in CLEAR_IF_FIRST handling in tdb

Volker Lendecke Volker.Lendecke at SerNet.DE
Sat Oct 6 07:35:17 MDT 2012


On Fri, Oct 05, 2012 at 03:52:43PM +0930, Rusty Russell wrote:
> Jeremy Allison <jra at samba.org> writes:
> 
> > However, inside tdb_oob() we already call
> > fstat(tdb->fd, &st), and then set:
> > tdb->map_size = st.st_size;
> > before returning from the tdb_oob() call.
> 
> Well, tdb_oob won't actually, because the file has actually shrunk:
> 
> 	if (st.st_size < (size_t)off + len) {
>                 ...
> 		return -1;
> 	}
> 
> But I do think it can be polished a little, to move that check to the
> bottom so we always map and remap when the size changes, even if it
> shrinks.  That not only covers this case, but tdb_check and tdb_rescue
> as well which use the same tdb_oob(tdb, tdb->map_size, 1, 1) trick.
> 
> Volker, what do you think of this patch in place of your "tdb: Make
> tdb_expand robust against shrinking tdbs"?

Fine by me, it fixes my testcase as well. Pushed that to
autobuild.

Thanks for the review!

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list