From 35cf4bb60ff9027d4ac7c4cf4fcf913abfdb92e7 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sun, 16 Sep 2018 18:37:56 +0300 Subject: [PATCH] mdbx: add validation for DUPSORT flags. Change-Id: Id1f3325764fb496413d060ea0468394f7e18ae37 --- src/mdbx.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/mdbx.c b/src/mdbx.c index 7dd484c1..8525edb0 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -11621,6 +11621,20 @@ int mdbx_dbi_open_ex(MDBX_txn *txn, const char *table_name, unsigned user_flags, if (unlikely(!txn || !dbi || (user_flags & ~VALID_FLAGS) != 0)) return MDBX_EINVAL; + switch (user_flags & + (MDBX_INTEGERDUP | MDBX_DUPFIXED | MDBX_DUPSORT | MDBX_REVERSEDUP)) { + default: + return MDBX_EINVAL; + case MDBX_DUPSORT: + case MDBX_DUPSORT | MDBX_REVERSEDUP: + case MDBX_DUPSORT | MDBX_DUPFIXED: + case MDBX_DUPSORT | MDBX_DUPFIXED | MDBX_REVERSEDUP: + case MDBX_DUPSORT | MDBX_DUPFIXED | MDBX_INTEGERDUP: + case MDBX_DUPSORT | MDBX_DUPFIXED | MDBX_INTEGERDUP | MDBX_REVERSEDUP: + case 0: + break; + } + if (unlikely(txn->mt_signature != MDBX_MT_SIGNATURE)) return MDBX_EBADSIGN;