From 89b0d5ac6cd7f2c47148a9ac87ce8d6aea40050b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 19 Jun 2012 12:38:33 +0930 Subject: 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 --- lib/ntdb/open.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/ntdb/open.c') 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; -- cgit