diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-07-30 13:09:33 -0700 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-08-04 16:50:43 +0930 |
commit | 1664d75ad3a5b710eaba9acb00d5996cd26cf2dc (patch) | |
tree | 725cb9de2f07ad63bc8822c8d9eb32dacd91d50a /ctdb/lib/tdb/common | |
parent | 6aa98fb041207bba4b84973c43689f0b9cfc29ce (diff) | |
download | samba-1664d75ad3a5b710eaba9acb00d5996cd26cf2dc.tar.gz samba-1664d75ad3a5b710eaba9acb00d5996cd26cf2dc.tar.xz samba-1664d75ad3a5b710eaba9acb00d5996cd26cf2dc.zip |
If the record is at the end of the database, pretending it has length 1 might take us out-of-bounds. Only pretend to be length 1 for the malloc.
(This used to be ctdb commit 6de2823f5f7976d4efa20761e518d6b67753f054)
Diffstat (limited to 'ctdb/lib/tdb/common')
-rw-r--r-- | ctdb/lib/tdb/common/io.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/ctdb/lib/tdb/common/io.c b/ctdb/lib/tdb/common/io.c index 172ab69d8c9..7c5f8a21665 100644 --- a/ctdb/lib/tdb/common/io.c +++ b/ctdb/lib/tdb/common/io.c @@ -381,11 +381,8 @@ unsigned char *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len unsigned char *buf; /* some systems don't like zero length malloc */ - if (len == 0) { - len = 1; - } - if (!(buf = (unsigned char *)malloc(len))) { + if (!(buf = (unsigned char *)malloc(len ? len : 1))) { /* Ensure ecode is set for log fn. */ tdb->ecode = TDB_ERR_OOM; TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_alloc_read malloc failed len=%d (%s)\n", |