diff --git a/libraries/liblmdb/CHANGES b/libraries/liblmdb/CHANGES
index fafaa404da..cf62eb48d6 100644
--- a/libraries/liblmdb/CHANGES
+++ b/libraries/liblmdb/CHANGES
@@ -1,5 +1,9 @@
LMDB 0.9 Change Log
+LMDB 0.9.20 Release (2017/01/11)
+ Fix mdb_load with escaped plaintext (ITS#8558)
+ Fix mdb_cursor_last / mdb_put interaction (ITS#8557)
+
LMDB 0.9.19 Release (2016/12/28)
Fix mdb_env_cwalk cursor init (ITS#8424)
Fix robust mutexes on Solaris 10/11 (ITS#8339)
diff --git a/libraries/liblmdb/COPYRIGHT b/libraries/liblmdb/COPYRIGHT
index fe4825af57..1508a735b6 100644
--- a/libraries/liblmdb/COPYRIGHT
+++ b/libraries/liblmdb/COPYRIGHT
@@ -1,4 +1,4 @@
-Copyright 2011-2016 Howard Chu, Symas Corp.
+Copyright 2011-2017 Howard Chu, Symas Corp.
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/intro.doc b/libraries/liblmdb/intro.doc
index 9fe9c22be1..f7bd8c0d02 100644
--- a/libraries/liblmdb/intro.doc
+++ b/libraries/liblmdb/intro.doc
@@ -1,5 +1,5 @@
/*
- * Copyright 2015-2016 Howard Chu, Symas Corp.
+ * Copyright 2015-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h
index 0aeff0d320..c444d91606 100644
--- a/libraries/liblmdb/lmdb.h
+++ b/libraries/liblmdb/lmdb.h
@@ -135,7 +135,7 @@
*
* @author Howard Chu, Symas Corporation.
*
- * @copyright Copyright 2011-2016 Howard Chu, Symas Corp. All rights reserved.
+ * @copyright Copyright 2011-2017 Howard Chu, Symas Corp. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
@@ -200,7 +200,7 @@ typedef int mdb_filehandle_t;
/** Library minor version */
#define MDB_VERSION_MINOR 9
/** Library patch version */
-#define MDB_VERSION_PATCH 19
+#define MDB_VERSION_PATCH 20
/** Combine args a,b,c into a single integer for easy version comparisons */
#define MDB_VERINT(a,b,c) (((a) << 24) | ((b) << 16) | (c))
@@ -210,7 +210,7 @@ typedef int mdb_filehandle_t;
MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH)
/** The release date of this library version */
-#define MDB_VERSION_DATE "December 28, 2016"
+#define MDB_VERSION_DATE "January 11, 2017"
/** A stringifier for the version info */
#define MDB_VERSTR(a,b,c,d) "LMDB " #a "." #b "." #c ": (" d ")"
diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c
index 23c1f009b0..fdc36bf1cb 100644
--- a/libraries/liblmdb/mdb.c
+++ b/libraries/liblmdb/mdb.c
@@ -5,7 +5,7 @@
* BerkeleyDB API, but much simplified.
*/
/*
- * Copyright 2011-2016 Howard Chu, Symas Corp.
+ * Copyright 2011-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -5459,8 +5459,17 @@ mdb_page_search_root(MDB_cursor *mc, MDB_val *key, int flags)
if (flags & (MDB_PS_FIRST|MDB_PS_LAST)) {
i = 0;
- if (flags & MDB_PS_LAST)
+ if (flags & MDB_PS_LAST) {
i = NUMKEYS(mp) - 1;
+ /* if already init'd, see if we're already in right place */
+ if (mc->mc_flags & C_INITIALIZED) {
+ if (mc->mc_ki[mc->mc_top] == i) {
+ mc->mc_top = mc->mc_snum++;
+ mp = mc->mc_pg[mc->mc_top];
+ goto ready;
+ }
+ }
+ }
} else {
int exact;
node = mdb_node_search(mc, key, &exact);
@@ -5486,6 +5495,7 @@ mdb_page_search_root(MDB_cursor *mc, MDB_val *key, int flags)
if ((rc = mdb_cursor_push(mc, mp)))
return rc;
+ready:
if (flags & MDB_PS_MODIFY) {
if ((rc = mdb_page_touch(mc)) != 0)
return rc;
@@ -5811,15 +5821,20 @@ mdb_cursor_next(MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op)
MDB_node *leaf;
int rc;
- if ((mc->mc_flags & C_EOF) ||
- ((mc->mc_flags & C_DEL) && op == MDB_NEXT_DUP)) {
+ if ((mc->mc_flags & C_DEL && op == MDB_NEXT_DUP))
return MDB_NOTFOUND;
- }
+
if (!(mc->mc_flags & C_INITIALIZED))
return mdb_cursor_first(mc, key, data);
mp = mc->mc_pg[mc->mc_top];
+ if (mc->mc_flags & C_EOF) {
+ if (mc->mc_ki[mc->mc_top] >= NUMKEYS(mp)-1)
+ return MDB_NOTFOUND;
+ mc->mc_flags ^= C_EOF;
+ }
+
if (mc->mc_db->md_flags & MDB_DUPSORT) {
leaf = NODEPTR(mp, mc->mc_ki[mc->mc_top]);
if (F_ISSET(leaf->mn_flags, F_DUPDATA)) {
@@ -6224,16 +6239,13 @@ mdb_cursor_last(MDB_cursor *mc, MDB_val *key, MDB_val *data)
if (mc->mc_xcursor)
mc->mc_xcursor->mx_cursor.mc_flags &= ~(C_INITIALIZED|C_EOF);
- if (!(mc->mc_flags & C_EOF)) {
-
- if (!(mc->mc_flags & C_INITIALIZED) || mc->mc_top) {
- rc = mdb_page_search(mc, NULL, MDB_PS_LAST);
- if (rc != MDB_SUCCESS)
- return rc;
- }
- mdb_cassert(mc, IS_LEAF(mc->mc_pg[mc->mc_top]));
-
+ if (!(mc->mc_flags & C_INITIALIZED) || mc->mc_top) {
+ rc = mdb_page_search(mc, NULL, MDB_PS_LAST);
+ if (rc != MDB_SUCCESS)
+ return rc;
}
+ mdb_cassert(mc, IS_LEAF(mc->mc_pg[mc->mc_top]));
+
mc->mc_ki[mc->mc_top] = NUMKEYS(mc->mc_pg[mc->mc_top]) - 1;
mc->mc_flags |= C_INITIALIZED|C_EOF;
leaf = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
@@ -6333,10 +6345,19 @@ mdb_cursor_get(MDB_cursor *mc, MDB_val *key, MDB_val *data,
rc = MDB_INCOMPATIBLE;
break;
}
- rc = MDB_SUCCESS;
- if (!(mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED) ||
- (mc->mc_xcursor->mx_cursor.mc_flags & C_EOF))
+ if (!(mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED)) {
+ rc = EINVAL;
break;
+ }
+ if (mc->mc_xcursor->mx_cursor.mc_flags & C_EOF) {
+ MDB_cursor *mx = &mc->mc_xcursor->mx_cursor;
+ if (mx->mc_ki[mx->mc_top] >= NUMKEYS(mx->mc_pg[mx->mc_top])-1) {
+ rc = MDB_NOTFOUND;
+ break;
+ }
+ mx->mc_flags ^= C_EOF;
+ }
+ rc = MDB_SUCCESS;
goto fetchm;
case MDB_NEXT_MULTIPLE:
if (data == NULL) {
@@ -7644,9 +7665,15 @@ mdb_cursor_count(MDB_cursor *mc, size_t *countp)
if (!(mc->mc_flags & C_INITIALIZED))
return EINVAL;
- if (!mc->mc_snum || (mc->mc_flags & C_EOF))
+ if (!mc->mc_snum)
return MDB_NOTFOUND;
+ if (mc->mc_flags & C_EOF) {
+ if (mc->mc_ki[mc->mc_top] >= NUMKEYS(mc->mc_pg[mc->mc_top]))
+ return MDB_NOTFOUND;
+ mc->mc_flags ^= C_EOF;
+ }
+
leaf = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
if (!F_ISSET(leaf->mn_flags, F_DUPDATA)) {
*countp = 1;
diff --git a/libraries/liblmdb/mdb_copy.1 b/libraries/liblmdb/mdb_copy.1
index 4387ac3a14..3b2af35aeb 100644
--- a/libraries/liblmdb/mdb_copy.1
+++ b/libraries/liblmdb/mdb_copy.1
@@ -1,5 +1,5 @@
-.TH MDB_COPY 1 "2014/06/20" "LMDB 0.9.14"
-.\" Copyright 2012-2016 Howard Chu, Symas Corp. All Rights Reserved.
+.TH MDB_COPY 1 "2014/07/01" "LMDB 0.9.14"
+.\" Copyright 2012-2017 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.SH NAME
mdb_copy \- LMDB environment copy tool
diff --git a/libraries/liblmdb/mdb_copy.c b/libraries/liblmdb/mdb_copy.c
index c953201097..c6ec71c7e6 100644
--- a/libraries/liblmdb/mdb_copy.c
+++ b/libraries/liblmdb/mdb_copy.c
@@ -1,6 +1,6 @@
/* mdb_copy.c - memory-mapped database backup tool */
/*
- * Copyright 2012-2016 Howard Chu, Symas Corp.
+ * Copyright 2012-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/mdb_dump.1 b/libraries/liblmdb/mdb_dump.1
index 0b95ca175a..c4bfcb382b 100644
--- a/libraries/liblmdb/mdb_dump.1
+++ b/libraries/liblmdb/mdb_dump.1
@@ -1,5 +1,5 @@
-.TH MDB_DUMP 1 "2014/06/20" "LMDB 0.9.14"
-.\" Copyright 2014-2016 Howard Chu, Symas Corp. All Rights Reserved.
+.TH MDB_DUMP 1 "2015/09/30" "LMDB 0.9.17"
+.\" Copyright 2014-2017 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.SH NAME
mdb_dump \- LMDB environment export tool
diff --git a/libraries/liblmdb/mdb_dump.c b/libraries/liblmdb/mdb_dump.c
index 17def6bc6c..537a499019 100644
--- a/libraries/liblmdb/mdb_dump.c
+++ b/libraries/liblmdb/mdb_dump.c
@@ -1,6 +1,6 @@
/* mdb_dump.c - memory-mapped database dump tool */
/*
- * Copyright 2011-2016 Howard Chu, Symas Corp.
+ * Copyright 2011-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/mdb_load.1 b/libraries/liblmdb/mdb_load.1
index 90ea5b9983..e25ff5a2b7 100644
--- a/libraries/liblmdb/mdb_load.1
+++ b/libraries/liblmdb/mdb_load.1
@@ -1,5 +1,5 @@
-.TH MDB_LOAD 1 "2014/06/20" "LMDB 0.9.14"
-.\" Copyright 2014-2016 Howard Chu, Symas Corp. All Rights Reserved.
+.TH MDB_LOAD 1 "2015/09/30" "LMDB 0.9.17"
+.\" Copyright 2014-2017 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.SH NAME
mdb_load \- LMDB environment import tool
diff --git a/libraries/liblmdb/mdb_load.c b/libraries/liblmdb/mdb_load.c
index 053cc88d25..d193a69211 100644
--- a/libraries/liblmdb/mdb_load.c
+++ b/libraries/liblmdb/mdb_load.c
@@ -1,6 +1,6 @@
/* mdb_load.c - memory-mapped database load tool */
/*
- * Copyright 2011-2016 Howard Chu, Symas Corp.
+ * Copyright 2011-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -248,7 +248,8 @@ badend:
c2 += 2;
}
} else {
- c1++; c2++;
+ /* copies are redundant when no escapes were used */
+ *c1++ = *c2++;
}
}
} else {
diff --git a/libraries/liblmdb/mdb_stat.1 b/libraries/liblmdb/mdb_stat.1
index b5ab6a9d23..3520c92ae3 100644
--- a/libraries/liblmdb/mdb_stat.1
+++ b/libraries/liblmdb/mdb_stat.1
@@ -1,5 +1,5 @@
-.TH MDB_STAT 1 "2014/06/20" "LMDB 0.9.14"
-.\" Copyright 2012-2016 Howard Chu, Symas Corp. All Rights Reserved.
+.TH MDB_STAT 1 "2015/09/30" "LMDB 0.9.17"
+.\" Copyright 2012-2017 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.SH NAME
mdb_stat \- LMDB environment status tool
diff --git a/libraries/liblmdb/mdb_stat.c b/libraries/liblmdb/mdb_stat.c
index a5cda2f3a5..51063accf6 100644
--- a/libraries/liblmdb/mdb_stat.c
+++ b/libraries/liblmdb/mdb_stat.c
@@ -1,6 +1,6 @@
/* mdb_stat.c - memory-mapped database status tool */
/*
- * Copyright 2011-2016 Howard Chu, Symas Corp.
+ * Copyright 2011-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/midl.c b/libraries/liblmdb/midl.c
index 6da3b8a541..1689c3ab7e 100644
--- a/libraries/liblmdb/midl.c
+++ b/libraries/liblmdb/midl.c
@@ -3,7 +3,8 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * Copyright 2000-2017 The OpenLDAP Foundation.
+ * Copyright 2000-2016 The OpenLDAP Foundation.
+ * Portions Copyright 2001-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/midl.h b/libraries/liblmdb/midl.h
index fb4370b773..df9414d0db 100644
--- a/libraries/liblmdb/midl.h
+++ b/libraries/liblmdb/midl.h
@@ -11,7 +11,8 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * Copyright 2000-2017 The OpenLDAP Foundation.
+ * Copyright 2000-2016 The OpenLDAP Foundation.
+ * Portions Copyright 2001-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/mtest.c b/libraries/liblmdb/mtest.c
index 28a33d4432..4a2eafd033 100644
--- a/libraries/liblmdb/mtest.c
+++ b/libraries/liblmdb/mtest.c
@@ -1,6 +1,6 @@
/* mtest.c - memory-mapped database tester/toy */
/*
- * Copyright 2011-2016 Howard Chu, Symas Corp.
+ * Copyright 2011-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/mtest2.c b/libraries/liblmdb/mtest2.c
index b68aade819..9691c04fad 100644
--- a/libraries/liblmdb/mtest2.c
+++ b/libraries/liblmdb/mtest2.c
@@ -1,6 +1,6 @@
/* mtest2.c - memory-mapped database tester/toy */
/*
- * Copyright 2011-2016 Howard Chu, Symas Corp.
+ * Copyright 2011-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/mtest3.c b/libraries/liblmdb/mtest3.c
index 73ee6e2144..4390d7ab4a 100644
--- a/libraries/liblmdb/mtest3.c
+++ b/libraries/liblmdb/mtest3.c
@@ -1,6 +1,6 @@
/* mtest3.c - memory-mapped database tester/toy */
/*
- * Copyright 2011-2016 Howard Chu, Symas Corp.
+ * Copyright 2011-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/mtest4.c b/libraries/liblmdb/mtest4.c
index 25666fffd3..9f7884a93f 100644
--- a/libraries/liblmdb/mtest4.c
+++ b/libraries/liblmdb/mtest4.c
@@ -1,6 +1,6 @@
/* mtest4.c - memory-mapped database tester/toy */
/*
- * Copyright 2011-2016 Howard Chu, Symas Corp.
+ * Copyright 2011-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/mtest5.c b/libraries/liblmdb/mtest5.c
index d3d7b6286d..4d34247e60 100644
--- a/libraries/liblmdb/mtest5.c
+++ b/libraries/liblmdb/mtest5.c
@@ -1,6 +1,6 @@
/* mtest5.c - memory-mapped database tester/toy */
/*
- * Copyright 2011-2016 Howard Chu, Symas Corp.
+ * Copyright 2011-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/mtest6.c b/libraries/liblmdb/mtest6.c
index 1b47db83f5..26904e88ba 100644
--- a/libraries/liblmdb/mtest6.c
+++ b/libraries/liblmdb/mtest6.c
@@ -1,6 +1,6 @@
/* mtest6.c - memory-mapped database tester/toy */
/*
- * Copyright 2011-2016 Howard Chu, Symas Corp.
+ * Copyright 2011-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/sample-bdb.txt b/libraries/liblmdb/sample-bdb.txt
index 11aff13f2e..4de26d5585 100644
--- a/libraries/liblmdb/sample-bdb.txt
+++ b/libraries/liblmdb/sample-bdb.txt
@@ -3,7 +3,7 @@
* Do a line-by-line comparison of this and sample-mdb.txt
*/
/*
- * Copyright 2012-2016 Howard Chu, Symas Corp.
+ * Copyright 2012-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/libraries/liblmdb/sample-mdb.txt b/libraries/liblmdb/sample-mdb.txt
index 5d3373736d..6e3622b866 100644
--- a/libraries/liblmdb/sample-mdb.txt
+++ b/libraries/liblmdb/sample-mdb.txt
@@ -3,7 +3,7 @@
* Do a line-by-line comparison of this and sample-bdb.txt
*/
/*
- * Copyright 2012-2016 Howard Chu, Symas Corp.
+ * Copyright 2012-2017 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without