Fix crash in admin command.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 23 Apr 2007 18:59:43 +0000 (20:59 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 23 Apr 2007 18:59:43 +0000 (20:59 +0200)
NEWS
src/admin.c

diff --git a/NEWS b/NEWS
index 1a95483349e2033ef8056efbb8aa46674a23e54b..354c4b1e0ed04ffd2283f65df68b9b17a55bd02e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ Ctrlproxy 3.0.3 UNRELEASED
 
     * Reset idle time when AWAY is used in auto-away (#121)
 
+       * Fix crash when using /CTRLPROXY without arguments
+
   INTERNALS
 
     * Use GIOChannels for reading the motd. 
index 67f2cb6a979bd34e1ca87cbc001ddc37191b8181..68235a7fef4c75e0ad334ab11eacc4bf2717e909 100644 (file)
@@ -487,10 +487,17 @@ gboolean process_cmd(admin_handle h, const char *cmd)
 gboolean admin_process_command(struct client *c, struct line *l, int cmdoffset)
 {
        int i;
-       char *tmp = g_strdup(l->args[cmdoffset]);
+       char *tmp;
        gboolean ret;
        struct admin_handle ah;
 
+       if (l->args[cmdoffset] == NULL) {
+               client_send_response(c, ERR_NEEDMOREPARAMS, l->args[0], "Not enough parameters", NULL);
+               return TRUE;
+       }
+
+       tmp = g_strdup(l->args[cmdoffset]);
+
        /* Add everything after l->args[cmdoffset] to tmp */
        for(i = cmdoffset+1; l->args[i]; i++) {
                char *oldtmp = tmp;