Commit 95c98eb3 authored by Rusty Russell's avatar Rusty Russell

tdb2: check for invalid flags in tdb_open.

This is vitally important for forwards compatibility.
parent 0cbedc52
...@@ -785,9 +785,15 @@ Status ...@@ -785,9 +785,15 @@ Status
\end_layout \end_layout
\begin_layout Standard \begin_layout Standard
\change_deleted 0 1300360559
Incomplete. Incomplete.
TDB_VOLATILE still defined, but implementation should fail on unknown flags TDB_VOLATILE still defined, but implementation should fail on unknown flags
to be future-proof. to be future-proof.
\change_inserted 0 1300360588
Complete.
Unknown flags cause tdb_open() to fail as well, so they can be detected
at runtime.
\end_layout \end_layout
\begin_layout Subsection \begin_layout Subsection
......
...@@ -237,6 +237,13 @@ struct tdb_context *tdb_open(const char *name, int tdb_flags, ...@@ -237,6 +237,13 @@ struct tdb_context *tdb_open(const char *name, int tdb_flags,
attr = attr->base.next; attr = attr->base.next;
} }
if (tdb_flags & ~(TDB_INTERNAL | TDB_NOLOCK | TDB_NOMMAP | TDB_CONVERT
| TDB_NOSYNC)) {
ecode = tdb_logerr(tdb, TDB_ERR_EINVAL, TDB_LOG_USE_ERROR,
"tdb_open: unknown flags %u", tdb_flags);
goto fail;
}
if ((open_flags & O_ACCMODE) == O_WRONLY) { if ((open_flags & O_ACCMODE) == O_WRONLY) {
ecode = tdb_logerr(tdb, TDB_ERR_EINVAL, TDB_LOG_USE_ERROR, ecode = tdb_logerr(tdb, TDB_ERR_EINVAL, TDB_LOG_USE_ERROR,
"tdb_open: can't open tdb %s write-only", "tdb_open: can't open tdb %s write-only",
......
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