Check if filename was provided for farious commands
authorChristian Thaeter <ct@pipapo.org>
Mon, 8 Oct 2007 10:43:41 +0000 (12:43 +0200)
committerChristian Thaeter <ct@pipapo.org>
Mon, 8 Oct 2007 10:43:41 +0000 (12:43 +0200)
rxpd.c

diff --git a/rxpd.c b/rxpd.c
index 61ab184..260d681 100644 (file)
--- a/rxpd.c
+++ b/rxpd.c
@@ -596,6 +596,12 @@ rxpd_connection_cmd_CHECK (int fd, short event, void* ptr)
             }
         }
     }
+  else if (!self->file)
+    {
+      rxpd_buffer_printf (&self->out, "#ERROR: no such file\n");
+      close (fd);
+      return;
+    }
 
   if (rxpd_buffer_state (&self->in) == RXPD_OK)
     rxpd_connection_schedule (self);
@@ -615,7 +621,15 @@ rxpd_connection_APPEND_PREPEND_helper (int fd, short event, void* ptr, int do_ap
   struct rxpd_connection* self = (struct rxpd_connection*) ptr;
 
   if (!event)
-    llist_init (&self->tmp_list);
+    {
+      if (!self->file)
+        {
+          rxpd_buffer_printf (&self->out, "#ERROR: no such file\n");
+          close (fd);
+          return;
+        }
+      llist_init (&self->tmp_list);
+    }
 
   if (event == EV_READ)
     {
@@ -703,6 +717,13 @@ rxpd_connection_cmd_DUMP (int fd, short event, void* ptr)
 {
   struct rxpd_connection* self = (struct rxpd_connection*) ptr;
 
+  if (!event && !self->file)
+    {
+      rxpd_buffer_printf (&self->out, "#ERROR: no such file\n");
+      close (fd);
+      return;
+    }
+
   if (llist_is_empty (&self->file->rules))
     rxpd_buffer_printf (&self->out, "#OK:\n");
   else