]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/parse.c
Commands received from other servers must have prefixes
[ngircd-alex.git] / src / ngircd / parse.c
index 8203dd0ecb2687617af5f911db820733d239d35d..31f048cf673408f08737647d66b8aba0bc807612 100644 (file)
@@ -276,11 +276,24 @@ Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Closed )
 
        *Closed = false;
 
-       if( ! Req->prefix ) return true;
-
        client = Conn_GetClient( Idx );
        assert( client != NULL );
 
+       if (!Req->prefix && Client_Type(client) == CLIENT_SERVER
+           && strcasecmp(Req->command, "ERROR") != 0
+           && strcasecmp(Req->command, "PING") != 0)
+       {
+               Log(LOG_ERR,
+                   "Received command without prefix (connection %d, command \"%s\")!?",
+                   Idx, Req->command);
+               if (!Conn_WriteStr(Idx, "ERROR :Prefix missing"))
+                       *Closed = true;
+               return false;
+       }
+
+       if (!Req->prefix)
+               return true;
+
        /* only validate if this connection is already registered */
        if (Client_Type(client) != CLIENT_USER
            && Client_Type(client) != CLIENT_SERVER