summaryrefslogtreecommitdiff
path: root/source3/tdb/tdb.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-04-07 19:39:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:31 -0500
commite79e98a9f6d5a3e619d454259a6affa2428e0ea9 (patch)
tree579f4c16328be08e79772dbbd35ad5fdc3784541 /source3/tdb/tdb.c
parentd761233aba3e8ed9abb0b7da81de86b3bf15667f (diff)
downloadsamba-e79e98a9f6d5a3e619d454259a6affa2428e0ea9.tar.gz
samba-e79e98a9f6d5a3e619d454259a6affa2428e0ea9.tar.bz2
samba-e79e98a9f6d5a3e619d454259a6affa2428e0ea9.zip
r6235: Partial fix for bugid #2581. Ensure if realloc fails on an internal
tdb we fail gracefully. Jeremy. (This used to be commit 28772dfca1f9e7afd01f7ea522cb2e697c318e22)
Diffstat (limited to 'source3/tdb/tdb.c')
-rw-r--r--source3/tdb/tdb.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index f153e2f258..7159550c0c 100644
--- a/source3/tdb/tdb.c
+++ b/source3/tdb/tdb.c
@@ -832,9 +832,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