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 c6c1123167dccdba966376c4cd37cece93a3c1f1..6ec4be5e6ad9c9adf811cfcdbd0d37cc0d2d6fc9 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 5fe0a2825cc82a7fe6bcb46d5e0702e4adfc8365..793525c57cb379a78fed49d1f409d5c66c80a5f0 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 7850c119c30a449c7fd3b0ae973d4a9a9219bf0b..a1012ba0e9ba570ee8c905dc4c2cf823d917b13a 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 519e6038b04eecf4022caf0b7c010d97e7e9777e..38edb645130ba8cb68675f15bb15bb27c7f8954f 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;
 }