]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/numeric.c
Don't send invalid CHANINFO commands when no key is set
[ngircd-alex.git] / src / ngircd / numeric.c
index 82e0cf0155a0cf32c939c9078731e9d09623c18f..8edb76e2169150951fbcdf9cb5611102b346d16f 100644 (file)
@@ -176,6 +176,7 @@ Synchronize_Lists(CLIENT * Client)
        CHANNEL *c;
        struct list_head *head;
        struct list_elem *elem;
+       time_t t;
 
        assert(Client != NULL);
 
@@ -183,9 +184,10 @@ Synchronize_Lists(CLIENT * Client)
        head = Class_GetList(CLASS_GLINE);
        elem = Lists_GetFirst(head);
        while (elem) {
+               t = Lists_GetValidity(elem) - time(NULL);
                if (!IRC_WriteStrClient(Client, "GLINE %s %ld :%s",
                                        Lists_GetMask(elem),
-                                       (long)(Lists_GetValidity(elem) - time(NULL)),
+                                       t > 0 ? (long)t : 0,
                                        Lists_GetReason(elem)))
                        return DISCONNECTED;
                elem = Lists_GetNext(elem);
@@ -212,7 +214,7 @@ Synchronize_Lists(CLIENT * Client)
 static bool
 Send_CHANINFO(CLIENT * Client, CHANNEL * Chan)
 {
-       char *modes, *topic;
+       char *modes, *topic, *key;
        bool has_k, has_l;
 
 #ifdef DEBUG
@@ -241,9 +243,10 @@ Send_CHANINFO(CLIENT * Client, CHANNEL * Chan)
                                          Channel_Name(Chan), modes, topic);
        }
        /* "CHANINFO <chan> +<modes> <key> <limit> :<topic>" */
+       key = Channel_Key(Chan);
        return IRC_WriteStrClient(Client, "CHANINFO %s +%s %s %lu :%s",
                                  Channel_Name(Chan), modes,
-                                 has_k ? Channel_Key(Chan) : "*",
+                                 has_k ? (key && *key ? key : "*") : "*",
                                  has_l ? Channel_MaxUsers(Chan) : 0, topic);
 } /* Send_CHANINFO */