From 744e31193913d117a68414fe163c9038a78edde2 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 1 Feb 2013 06:19:23 -0800 Subject: [PATCH] NULL key is allowed for MDB_CURRENT --- libraries/liblmdb/mdb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 578e6b6979..36b02a3452 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -1095,6 +1095,10 @@ mdb_dkey(MDB_val *key, char *buf) char *ptr = buf; unsigned char *c = key->mv_data; unsigned int i; + + if (!key) + return ""; + if (key->mv_size > MDB_MAXKEYSIZE) return "MDB_MAXKEYSIZE"; /* may want to make this a dynamic check: if the key is mostly @@ -4823,7 +4827,7 @@ mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data, if (F_ISSET(mc->mc_txn->mt_flags, MDB_TXN_RDONLY)) return EACCES; - if (key->mv_size == 0 || key->mv_size > MDB_MAXKEYSIZE) + if (flags != MDB_CURRENT && (key->mv_size == 0 || key->mv_size > MDB_MAXKEYSIZE)) return EINVAL; if (F_ISSET(mc->mc_db->md_flags, MDB_DUPSORT) && data->mv_size > MDB_MAXKEYSIZE) -- 2.39.5