]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/parse.c
Allow pre-defined server local channels ("&").
[ngircd-alex.git] / src / ngircd / parse.c
index 00ae3cd7e93d5f415a596d3d4c6b50ffb27c7817..ec856a0c28fc05ff33b5d1930c79ee4bdb3f75b1 100644 (file)
@@ -338,14 +338,27 @@ Validate_Command( UNUSED CONN_ID Idx, UNUSED REQUEST *Req, bool *Closed )
 
 
 static bool
+#ifdef STRICT_RFC
 Validate_Args(CONN_ID Idx, REQUEST *Req, bool *Closed)
+#else
+Validate_Args(UNUSED CONN_ID Idx, UNUSED REQUEST *Req, bool *Closed)
+#endif
 {
+#ifdef STRICT_RFC
        int i;
+#endif
 
+       *Closed = false;
+
+#ifdef STRICT_RFC
        assert( Idx >= 0 );
        assert( Req != NULL );
-       *Closed = false;
 
+       /* CR and LF are never allowed in command parameters.
+        * But since we do accept lines terminated only with CR or LF in
+        * "non-RFC-compliant mode" (besides the correct CR+LF combination),
+        * this check can only trigger in "strict RFC" mode; therefore we
+        * optimize it away otherwise ... */
        for (i = 0; i < Req->argc; i++) {
                if (strchr(Req->argv[i], '\r') || strchr(Req->argv[i], '\n')) {
                        Log(LOG_ERR,
@@ -357,6 +370,8 @@ Validate_Args(CONN_ID Idx, REQUEST *Req, bool *Closed)
                        return false;
                }
        }
+#endif
+
        return true;
 } /* Validate_Args */
 
@@ -366,7 +381,8 @@ static bool
 Handle_Numeric(CLIENT *client, REQUEST *Req)
 {
        static const struct _NUMERIC Numerics[] = {
-               { 005, IRC_Num_ISUPPORT },
+               {   5, IRC_Num_ISUPPORT },
+               {  20, NULL },
                { 376, IRC_Num_ENDOFMOTD }
        };
        int i, num;
@@ -374,8 +390,12 @@ Handle_Numeric(CLIENT *client, REQUEST *Req)
        CLIENT *prefix, *target = NULL;
 
        /* Determine target */
-       if (Req->argc > 0)
-               target = Client_Search(Req->argv[0]);
+       if (Req->argc > 0) {
+               if (strcmp(Req->argv[0], "*") != 0)
+                       target = Client_Search(Req->argv[0]);
+               else
+                       target = Client_ThisServer();
+       }
 
        if (!target) {
                /* Status code without target!? */
@@ -394,8 +414,11 @@ Handle_Numeric(CLIENT *client, REQUEST *Req)
                num = atoi(Req->command);
 
                for (i = 0; i < (int) ARRAY_SIZE(Numerics); i++) {
-                       if (num == Numerics[i].numeric)
+                       if (num == Numerics[i].numeric) {
+                               if (!Numerics[i].function)
+                                       return CONNECTED;
                                return Numerics[i].function(client, Req);
+                       }
                }
 
                LogDebug("Ignored status code %s from \"%s\".",