Commit 195b605e authored by Rusty Russell's avatar Rusty Russell

Fix theoretical problem with 0-length records.

By faking them out to length 1, we might go oob.  Just fake the malloc.
parent 6d35d746
...@@ -383,11 +383,7 @@ unsigned char *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len ...@@ -383,11 +383,7 @@ unsigned char *tdb_alloc_read(struct tdb_context *tdb, tdb_off_t offset, tdb_len
unsigned char *buf; unsigned char *buf;
/* some systems don't like zero length malloc */ /* some systems don't like zero length malloc */
if (len == 0) { if (!(buf = (unsigned char *)malloc(len ? len : 1))) {
len = 1;
}
if (!(buf = (unsigned char *)malloc(len))) {
/* Ensure ecode is set for log fn. */ /* Ensure ecode is set for log fn. */
tdb->ecode = TDB_ERR_OOM; tdb->ecode = TDB_ERR_OOM;
TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_alloc_read malloc failed len=%d (%s)\n", TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_alloc_read malloc failed len=%d (%s)\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment