From 1c0d78bd318594a3ec6b35a9b7015c010c48ffc2 Mon Sep 17 00:00:00 2001 Message-Id: <1c0d78bd318594a3ec6b35a9b7015c010c48ffc2.1714139667.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 15 Jul 2007 15:05:32 +0100 Subject: [PATCH] disobedience: don't crash if no password Organization: Straylight/Edgeware From: Richard Kettlewell --- disobedience/client.c | 4 ++++ disobedience/disobedience.c | 5 +++-- lib/authhash.c | 5 ++++- lib/eclient.c | 4 ++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/disobedience/client.c b/disobedience/client.c index c6c1123..6ec4be5 100644 --- a/disobedience/client.c +++ b/disobedience/client.c @@ -161,6 +161,10 @@ disorder_eclient *gtkclient(void) { esource = (struct eclient_source *)source; esource->pollfd.fd = -1; esource->client = disorder_eclient_new(>kclient_callbacks, source); + if(!esource->client) { + g_source_destroy(source); + return 0; + } g_source_attach(source, 0); return esource->client; } diff --git a/disobedience/disobedience.c b/disobedience/disobedience.c index 5fe0a28..793525c 100644 --- a/disobedience/disobedience.c +++ b/disobedience/disobedience.c @@ -341,8 +341,9 @@ int main(int argc, char **argv) { mainloop = g_main_loop_new(0, 0); if(config_read()) fatal(0, "cannot read configuration"); /* create the clients */ - client = gtkclient(); - logclient = gtkclient(); + if(!(client = gtkclient()) + || !(logclient = gtkclient())) + return 1; /* already reported an error */ disorder_eclient_log(logclient, &gdisorder_log_callbacks, 0); /* periodic operations (e.g. expiring the cache) */ g_timeout_add(600000/*milliseconds*/, periodic, 0); diff --git a/lib/authhash.c b/lib/authhash.c index 7850c11..a1012ba 100644 --- a/lib/authhash.c +++ b/lib/authhash.c @@ -23,6 +23,7 @@ #include #include +#include #include "hex.h" #include "log.h" @@ -36,7 +37,9 @@ const char *authhash(const void *challenge, size_t nchallenge, const char *password) { gcrypt_hash_handle h; const char *res; - + + assert(challenge != 0); + assert(password != 0); #if HAVE_GCRY_ERROR_T { gcry_error_t e; diff --git a/lib/eclient.c b/lib/eclient.c index 519e603..38edb64 100644 --- a/lib/eclient.c +++ b/lib/eclient.c @@ -194,6 +194,10 @@ disorder_eclient *disorder_eclient_new(const disorder_eclient_callbacks *cb, vector_init(&c->vec); dynstr_init(&c->input); dynstr_init(&c->output); + if(!config->password) { + error(0, "no password set"); + return 0; + } return c; } -- [mdw]