chiark / gitweb /
disobedience: don't crash if no password
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 15 Jul 2007 14:05:32 +0000 (15:05 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 15 Jul 2007 14:05:32 +0000 (15:05 +0100)
disobedience/client.c
disobedience/disobedience.c
lib/authhash.c
lib/eclient.c

index c6c1123..6ec4be5 100644 (file)
@@ -161,6 +161,10 @@ disorder_eclient *gtkclient(void) {
   esource = (struct eclient_source *)source;
   esource->pollfd.fd = -1;
   esource->client = disorder_eclient_new(&gtkclient_callbacks, source);
+  if(!esource->client) {
+    g_source_destroy(source);
+    return 0;
+  }
   g_source_attach(source, 0);
   return esource->client;
 }
index 5fe0a28..793525c 100644 (file)
@@ -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);
index 7850c11..a1012ba 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <stddef.h>
 #include <gcrypt.h>
+#include <assert.h>
 
 #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;
index 519e603..38edb64 100644 (file)
@@ -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;
 }