diff options
author | Jeremy Allison <jra@samba.org> | 2005-04-07 19:50:54 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:11:28 -0500 |
commit | e3775ee8501e2f15ee172970085c2c12e50da1cf (patch) | |
tree | 6cd6a342510047c258e354ab6ea7f3ffcd6d1683 /source4/lib/tdb | |
parent | c46c6e23ba7b962e20f49eeff3c3842ce905ec4a (diff) | |
download | samba-e3775ee8501e2f15ee172970085c2c12e50da1cf.tar.gz samba-e3775ee8501e2f15ee172970085c2c12e50da1cf.tar.bz2 samba-e3775ee8501e2f15ee172970085c2c12e50da1cf.zip |
r6238: Ensure if realloc fails on an internal
tdb we fail gracefully.
Jeremy.
(This used to be commit d69f7c05468ae54e0474b188fedabe14e7297d53)
Diffstat (limited to 'source4/lib/tdb')
-rw-r--r-- | source4/lib/tdb/common/tdb.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/source4/lib/tdb/common/tdb.c b/source4/lib/tdb/common/tdb.c index d9fabaeda9..6554ec5697 100644 --- a/source4/lib/tdb/common/tdb.c +++ b/source4/lib/tdb/common/tdb.c @@ -802,9 +802,14 @@ static int tdb_expand(TDB_CONTEXT *tdb, tdb_off size) tdb->map_size += size; - if (tdb->flags & TDB_INTERNAL) - tdb->map_ptr = realloc(tdb->map_ptr, tdb->map_size); - else { + if (tdb->flags & TDB_INTERNAL) { + char *new_map_ptr = realloc(tdb->map_ptr, tdb->map_size); + if (!new_map_ptr) { + tdb->map_size -= size; + goto fail; + } + tdb->map_ptr = new_map_ptr; + } else { /* * We must ensure the file is remapped before adding the space * to ensure consistency with systems like OpenBSD where |