diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2012-06-19 12:38:33 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-06-19 05:38:06 +0200 |
commit | 89b0d5ac6cd7f2c47148a9ac87ce8d6aea40050b (patch) | |
tree | 7834c6c649151ccdfb1a8bd4a6e2fffa57354896 /lib/ntdb/open.c | |
parent | 7fae6c44e2ffd720af406d1e0b48c08007091aab (diff) | |
download | samba-89b0d5ac6cd7f2c47148a9ac87ce8d6aea40050b.tar.gz samba-89b0d5ac6cd7f2c47148a9ac87ce8d6aea40050b.tar.bz2 samba-89b0d5ac6cd7f2c47148a9ac87ce8d6aea40050b.zip |
ntdb: simply disallow NULL names.
TDB allows this for internal databases, but it's a bad idea, since the
name is useful for logging.
They're a hassle to deal with, and we'd just end up putting "unnamed"
in there, so let the user deal with it. If they don't, they get an
informative core dump.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/ntdb/open.c')
-rw-r--r-- | lib/ntdb/open.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/ntdb/open.c b/lib/ntdb/open.c index 5a781c9328..01a0928074 100644 --- a/lib/ntdb/open.c +++ b/lib/ntdb/open.c @@ -422,18 +422,14 @@ _PUBLIC_ struct ntdb_context *ntdb_open(const char *name, int ntdb_flags, enum NTDB_ERROR ecode; int openlock; - ntdb = malloc(sizeof(*ntdb) + (name ? strlen(name) + 1 : 0)); + ntdb = malloc(sizeof(*ntdb) + strlen(name) + 1); if (!ntdb) { /* Can't log this */ errno = ENOMEM; return NULL; } /* Set name immediately for logging functions. */ - if (name) { - ntdb->name = strcpy((char *)(ntdb + 1), name); - } else { - ntdb->name = NULL; - } + ntdb->name = strcpy((char *)(ntdb + 1), name); ntdb->flags = ntdb_flags; ntdb->log_fn = NULL; ntdb->open_flags = open_flags; |